diff options
| author | 2018-12-03 17:04:05 -0500 | |
|---|---|---|
| committer | 2018-12-03 17:04:05 -0500 | |
| commit | f7d5f7294425f59bb9d7c417fa04efcbd49ced91 (patch) | |
| tree | fd398c37a6a276a56ab4265bfaa59904f3762e34 /src/core/file_sys | |
| parent | Merge pull request #1839 from lioncash/init (diff) | |
| parent | file_sys: Override missing mutating functions to be stubbed out for ReadOnlyV... (diff) | |
| download | yuzu-f7d5f7294425f59bb9d7c417fa04efcbd49ced91.tar.gz yuzu-f7d5f7294425f59bb9d7c417fa04efcbd49ced91.tar.xz yuzu-f7d5f7294425f59bb9d7c417fa04efcbd49ced91.zip | |
Merge pull request #1833 from lioncash/clean
service/fsp_srv: Implement CleanDirectoryRecursively
Diffstat (limited to 'src/core/file_sys')
| -rw-r--r-- | src/core/file_sys/vfs.cpp | 46 | ||||
| -rw-r--r-- | src/core/file_sys/vfs.h | 20 |
2 files changed, 62 insertions, 4 deletions
diff --git a/src/core/file_sys/vfs.cpp b/src/core/file_sys/vfs.cpp index 7b584de7f..e33327ef0 100644 --- a/src/core/file_sys/vfs.cpp +++ b/src/core/file_sys/vfs.cpp | |||
| @@ -384,6 +384,28 @@ bool VfsDirectory::DeleteSubdirectoryRecursive(std::string_view name) { | |||
| 384 | return success; | 384 | return success; |
| 385 | } | 385 | } |
| 386 | 386 | ||
| 387 | bool VfsDirectory::CleanSubdirectoryRecursive(std::string_view name) { | ||
| 388 | auto dir = GetSubdirectory(name); | ||
| 389 | if (dir == nullptr) { | ||
| 390 | return false; | ||
| 391 | } | ||
| 392 | |||
| 393 | bool success = true; | ||
| 394 | for (const auto& file : dir->GetFiles()) { | ||
| 395 | if (!dir->DeleteFile(file->GetName())) { | ||
| 396 | success = false; | ||
| 397 | } | ||
| 398 | } | ||
| 399 | |||
| 400 | for (const auto& sdir : dir->GetSubdirectories()) { | ||
| 401 | if (!dir->DeleteSubdirectoryRecursive(sdir->GetName())) { | ||
| 402 | success = false; | ||
| 403 | } | ||
| 404 | } | ||
| 405 | |||
| 406 | return success; | ||
| 407 | } | ||
| 408 | |||
| 387 | bool VfsDirectory::Copy(std::string_view src, std::string_view dest) { | 409 | bool VfsDirectory::Copy(std::string_view src, std::string_view dest) { |
| 388 | const auto f1 = GetFile(src); | 410 | const auto f1 = GetFile(src); |
| 389 | auto f2 = CreateFile(dest); | 411 | auto f2 = CreateFile(dest); |
| @@ -431,10 +453,34 @@ std::shared_ptr<VfsFile> ReadOnlyVfsDirectory::CreateFile(std::string_view name) | |||
| 431 | return nullptr; | 453 | return nullptr; |
| 432 | } | 454 | } |
| 433 | 455 | ||
| 456 | std::shared_ptr<VfsFile> ReadOnlyVfsDirectory::CreateFileAbsolute(std::string_view path) { | ||
| 457 | return nullptr; | ||
| 458 | } | ||
| 459 | |||
| 460 | std::shared_ptr<VfsFile> ReadOnlyVfsDirectory::CreateFileRelative(std::string_view path) { | ||
| 461 | return nullptr; | ||
| 462 | } | ||
| 463 | |||
| 464 | std::shared_ptr<VfsDirectory> ReadOnlyVfsDirectory::CreateDirectoryAbsolute(std::string_view path) { | ||
| 465 | return nullptr; | ||
| 466 | } | ||
| 467 | |||
| 468 | std::shared_ptr<VfsDirectory> ReadOnlyVfsDirectory::CreateDirectoryRelative(std::string_view path) { | ||
| 469 | return nullptr; | ||
| 470 | } | ||
| 471 | |||
| 434 | bool ReadOnlyVfsDirectory::DeleteSubdirectory(std::string_view name) { | 472 | bool ReadOnlyVfsDirectory::DeleteSubdirectory(std::string_view name) { |
| 435 | return false; | 473 | return false; |
| 436 | } | 474 | } |
| 437 | 475 | ||
| 476 | bool ReadOnlyVfsDirectory::DeleteSubdirectoryRecursive(std::string_view name) { | ||
| 477 | return false; | ||
| 478 | } | ||
| 479 | |||
| 480 | bool ReadOnlyVfsDirectory::CleanSubdirectoryRecursive(std::string_view name) { | ||
| 481 | return false; | ||
| 482 | } | ||
| 483 | |||
| 438 | bool ReadOnlyVfsDirectory::DeleteFile(std::string_view name) { | 484 | bool ReadOnlyVfsDirectory::DeleteFile(std::string_view name) { |
| 439 | return false; | 485 | return false; |
| 440 | } | 486 | } |
diff --git a/src/core/file_sys/vfs.h b/src/core/file_sys/vfs.h index 002f99d4e..e5641b255 100644 --- a/src/core/file_sys/vfs.h +++ b/src/core/file_sys/vfs.h | |||
| @@ -245,12 +245,18 @@ public: | |||
| 245 | // any failure. | 245 | // any failure. |
| 246 | virtual std::shared_ptr<VfsDirectory> CreateDirectoryAbsolute(std::string_view path); | 246 | virtual std::shared_ptr<VfsDirectory> CreateDirectoryAbsolute(std::string_view path); |
| 247 | 247 | ||
| 248 | // Deletes the subdirectory with name and returns true on success. | 248 | // Deletes the subdirectory with the given name and returns true on success. |
| 249 | virtual bool DeleteSubdirectory(std::string_view name) = 0; | 249 | virtual bool DeleteSubdirectory(std::string_view name) = 0; |
| 250 | // Deletes all subdirectories and files of subdirectory with name recirsively and then deletes | 250 | |
| 251 | // the subdirectory. Returns true on success. | 251 | // Deletes all subdirectories and files within the provided directory and then deletes |
| 252 | // the directory itself. Returns true on success. | ||
| 252 | virtual bool DeleteSubdirectoryRecursive(std::string_view name); | 253 | virtual bool DeleteSubdirectoryRecursive(std::string_view name); |
| 253 | // Returnes whether or not the file with name name was deleted successfully. | 254 | |
| 255 | // Deletes all subdirectories and files within the provided directory. | ||
| 256 | // Unlike DeleteSubdirectoryRecursive, this does not delete the provided directory. | ||
| 257 | virtual bool CleanSubdirectoryRecursive(std::string_view name); | ||
| 258 | |||
| 259 | // Returns whether or not the file with name name was deleted successfully. | ||
| 254 | virtual bool DeleteFile(std::string_view name) = 0; | 260 | virtual bool DeleteFile(std::string_view name) = 0; |
| 255 | 261 | ||
| 256 | // Returns whether or not this directory was renamed to name. | 262 | // Returns whether or not this directory was renamed to name. |
| @@ -276,7 +282,13 @@ public: | |||
| 276 | bool IsReadable() const override; | 282 | bool IsReadable() const override; |
| 277 | std::shared_ptr<VfsDirectory> CreateSubdirectory(std::string_view name) override; | 283 | std::shared_ptr<VfsDirectory> CreateSubdirectory(std::string_view name) override; |
| 278 | std::shared_ptr<VfsFile> CreateFile(std::string_view name) override; | 284 | std::shared_ptr<VfsFile> CreateFile(std::string_view name) override; |
| 285 | std::shared_ptr<VfsFile> CreateFileAbsolute(std::string_view path) override; | ||
| 286 | std::shared_ptr<VfsFile> CreateFileRelative(std::string_view path) override; | ||
| 287 | std::shared_ptr<VfsDirectory> CreateDirectoryAbsolute(std::string_view path) override; | ||
| 288 | std::shared_ptr<VfsDirectory> CreateDirectoryRelative(std::string_view path) override; | ||
| 279 | bool DeleteSubdirectory(std::string_view name) override; | 289 | bool DeleteSubdirectory(std::string_view name) override; |
| 290 | bool DeleteSubdirectoryRecursive(std::string_view name) override; | ||
| 291 | bool CleanSubdirectoryRecursive(std::string_view name) override; | ||
| 280 | bool DeleteFile(std::string_view name) override; | 292 | bool DeleteFile(std::string_view name) override; |
| 281 | bool Rename(std::string_view name) override; | 293 | bool Rename(std::string_view name) override; |
| 282 | }; | 294 | }; |