diff options
| author | 2016-10-14 15:29:09 +0800 | |
|---|---|---|
| committer | 2016-11-01 18:30:32 +0200 | |
| commit | 4dd8a831bd5ea32108db837754289ab42a2fa6ca (patch) | |
| tree | 0aaf5cc1c8966446c4aa5d4e79d02641b7e4ba30 /src | |
| parent | Merge pull request #2147 from Pringo/readme-donate (diff) | |
| download | yuzu-4dd8a831bd5ea32108db837754289ab42a2fa6ca.tar.gz yuzu-4dd8a831bd5ea32108db837754289ab42a2fa6ca.tar.xz yuzu-4dd8a831bd5ea32108db837754289ab42a2fa6ca.zip | |
FileSys: make Archive interfaces return error code
and make the mode parameter a reference since it is a BitField union
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/file_sys/archive_backend.h | 28 | ||||
| -rw-r--r-- | src/core/file_sys/disk_archive.cpp | 50 | ||||
| -rw-r--r-- | src/core/file_sys/disk_archive.h | 14 | ||||
| -rw-r--r-- | src/core/file_sys/ivfc_archive.cpp | 31 | ||||
| -rw-r--r-- | src/core/file_sys/ivfc_archive.h | 14 | ||||
| -rw-r--r-- | src/core/hle/service/fs/archive.cpp | 41 |
6 files changed, 91 insertions, 87 deletions
diff --git a/src/core/file_sys/archive_backend.h b/src/core/file_sys/archive_backend.h index 06b8f2ed7..58f6c150c 100644 --- a/src/core/file_sys/archive_backend.h +++ b/src/core/file_sys/archive_backend.h | |||
| @@ -87,7 +87,7 @@ public: | |||
| 87 | * @return Opened file, or error code | 87 | * @return Opened file, or error code |
| 88 | */ | 88 | */ |
| 89 | virtual ResultVal<std::unique_ptr<FileBackend>> OpenFile(const Path& path, | 89 | virtual ResultVal<std::unique_ptr<FileBackend>> OpenFile(const Path& path, |
| 90 | const Mode mode) const = 0; | 90 | const Mode& mode) const = 0; |
| 91 | 91 | ||
| 92 | /** | 92 | /** |
| 93 | * Delete a file specified by its path | 93 | * Delete a file specified by its path |
| @@ -100,53 +100,53 @@ public: | |||
| 100 | * Rename a File specified by its path | 100 | * Rename a File specified by its path |
| 101 | * @param src_path Source path relative to the archive | 101 | * @param src_path Source path relative to the archive |
| 102 | * @param dest_path Destination path relative to the archive | 102 | * @param dest_path Destination path relative to the archive |
| 103 | * @return Whether rename succeeded | 103 | * @return Result of the operation |
| 104 | */ | 104 | */ |
| 105 | virtual bool RenameFile(const Path& src_path, const Path& dest_path) const = 0; | 105 | virtual ResultCode RenameFile(const Path& src_path, const Path& dest_path) const = 0; |
| 106 | 106 | ||
| 107 | /** | 107 | /** |
| 108 | * Delete a directory specified by its path | 108 | * Delete a directory specified by its path |
| 109 | * @param path Path relative to the archive | 109 | * @param path Path relative to the archive |
| 110 | * @return Whether the directory could be deleted | 110 | * @return Result of the operation |
| 111 | */ | 111 | */ |
| 112 | virtual bool DeleteDirectory(const Path& path) const = 0; | 112 | virtual ResultCode DeleteDirectory(const Path& path) const = 0; |
| 113 | 113 | ||
| 114 | /** | 114 | /** |
| 115 | * Delete a directory specified by its path and anything under it | 115 | * Delete a directory specified by its path and anything under it |
| 116 | * @param path Path relative to the archive | 116 | * @param path Path relative to the archive |
| 117 | * @return Whether the directory could be deleted | 117 | * @return Result of the operation |
| 118 | */ | 118 | */ |
| 119 | virtual bool DeleteDirectoryRecursively(const Path& path) const = 0; | 119 | virtual ResultCode DeleteDirectoryRecursively(const Path& path) const = 0; |
| 120 | 120 | ||
| 121 | /** | 121 | /** |
| 122 | * Create a file specified by its path | 122 | * Create a file specified by its path |
| 123 | * @param path Path relative to the Archive | 123 | * @param path Path relative to the Archive |
| 124 | * @param size The size of the new file, filled with zeroes | 124 | * @param size The size of the new file, filled with zeroes |
| 125 | * @return File creation result code | 125 | * @return Result of the operation |
| 126 | */ | 126 | */ |
| 127 | virtual ResultCode CreateFile(const Path& path, u64 size) const = 0; | 127 | virtual ResultCode CreateFile(const Path& path, u64 size) const = 0; |
| 128 | 128 | ||
| 129 | /** | 129 | /** |
| 130 | * Create a directory specified by its path | 130 | * Create a directory specified by its path |
| 131 | * @param path Path relative to the archive | 131 | * @param path Path relative to the archive |
| 132 | * @return Whether the directory could be created | 132 | * @return Result of the operation |
| 133 | */ | 133 | */ |
| 134 | virtual bool CreateDirectory(const Path& path) const = 0; | 134 | virtual ResultCode CreateDirectory(const Path& path) const = 0; |
| 135 | 135 | ||
| 136 | /** | 136 | /** |
| 137 | * Rename a Directory specified by its path | 137 | * Rename a Directory specified by its path |
| 138 | * @param src_path Source path relative to the archive | 138 | * @param src_path Source path relative to the archive |
| 139 | * @param dest_path Destination path relative to the archive | 139 | * @param dest_path Destination path relative to the archive |
| 140 | * @return Whether rename succeeded | 140 | * @return Result of the operation |
| 141 | */ | 141 | */ |
| 142 | virtual bool RenameDirectory(const Path& src_path, const Path& dest_path) const = 0; | 142 | virtual ResultCode RenameDirectory(const Path& src_path, const Path& dest_path) const = 0; |
| 143 | 143 | ||
| 144 | /** | 144 | /** |
| 145 | * Open a directory specified by its path | 145 | * Open a directory specified by its path |
| 146 | * @param path Path relative to the archive | 146 | * @param path Path relative to the archive |
| 147 | * @return Opened directory, or nullptr | 147 | * @return Opened directory, or error code |
| 148 | */ | 148 | */ |
| 149 | virtual std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const = 0; | 149 | virtual ResultVal<std::unique_ptr<DirectoryBackend>> OpenDirectory(const Path& path) const = 0; |
| 150 | 150 | ||
| 151 | /** | 151 | /** |
| 152 | * Get the free space | 152 | * Get the free space |
diff --git a/src/core/file_sys/disk_archive.cpp b/src/core/file_sys/disk_archive.cpp index 2f05af361..ce6b9360b 100644 --- a/src/core/file_sys/disk_archive.cpp +++ b/src/core/file_sys/disk_archive.cpp | |||
| @@ -16,7 +16,7 @@ | |||
| 16 | namespace FileSys { | 16 | namespace FileSys { |
| 17 | 17 | ||
| 18 | ResultVal<std::unique_ptr<FileBackend>> DiskArchive::OpenFile(const Path& path, | 18 | ResultVal<std::unique_ptr<FileBackend>> DiskArchive::OpenFile(const Path& path, |
| 19 | const Mode mode) const { | 19 | const Mode& mode) const { |
| 20 | LOG_DEBUG(Service_FS, "called path=%s mode=%01X", path.DebugStr().c_str(), mode.hex); | 20 | LOG_DEBUG(Service_FS, "called path=%s mode=%01X", path.DebugStr().c_str(), mode.hex); |
| 21 | auto file = std::make_unique<DiskFile>(*this, path, mode); | 21 | auto file = std::make_unique<DiskFile>(*this, path, mode); |
| 22 | ResultCode result = file->Open(); | 22 | ResultCode result = file->Open(); |
| @@ -43,16 +43,28 @@ ResultCode DiskArchive::DeleteFile(const Path& path) const { | |||
| 43 | ErrorLevel::Status); | 43 | ErrorLevel::Status); |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | bool DiskArchive::RenameFile(const Path& src_path, const Path& dest_path) const { | 46 | ResultCode DiskArchive::RenameFile(const Path& src_path, const Path& dest_path) const { |
| 47 | return FileUtil::Rename(mount_point + src_path.AsString(), mount_point + dest_path.AsString()); | 47 | if (FileUtil::Rename(mount_point + src_path.AsString(), mount_point + dest_path.AsString())) |
| 48 | return RESULT_SUCCESS; | ||
| 49 | |||
| 50 | // TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't | ||
| 51 | // exist or similar. Verify. | ||
| 52 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description | ||
| 53 | ErrorSummary::NothingHappened, ErrorLevel::Status); | ||
| 48 | } | 54 | } |
| 49 | 55 | ||
| 50 | bool DiskArchive::DeleteDirectory(const Path& path) const { | 56 | ResultCode DiskArchive::DeleteDirectory(const Path& path) const { |
| 51 | return FileUtil::DeleteDir(mount_point + path.AsString()); | 57 | if (FileUtil::DeleteDir(mount_point + path.AsString())) |
| 58 | return RESULT_SUCCESS; | ||
| 59 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description | ||
| 60 | ErrorSummary::Canceled, ErrorLevel::Status); | ||
| 52 | } | 61 | } |
| 53 | 62 | ||
| 54 | bool DiskArchive::DeleteDirectoryRecursively(const Path& path) const { | 63 | ResultCode DiskArchive::DeleteDirectoryRecursively(const Path& path) const { |
| 55 | return FileUtil::DeleteDirRecursively(mount_point + path.AsString()); | 64 | if (FileUtil::DeleteDirRecursively(mount_point + path.AsString())) |
| 65 | return RESULT_SUCCESS; | ||
| 66 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description | ||
| 67 | ErrorSummary::Canceled, ErrorLevel::Status); | ||
| 56 | } | 68 | } |
| 57 | 69 | ||
| 58 | ResultCode DiskArchive::CreateFile(const FileSys::Path& path, u64 size) const { | 70 | ResultCode DiskArchive::CreateFile(const FileSys::Path& path, u64 size) const { |
| @@ -81,20 +93,30 @@ ResultCode DiskArchive::CreateFile(const FileSys::Path& path, u64 size) const { | |||
| 81 | ErrorLevel::Info); | 93 | ErrorLevel::Info); |
| 82 | } | 94 | } |
| 83 | 95 | ||
| 84 | bool DiskArchive::CreateDirectory(const Path& path) const { | 96 | ResultCode DiskArchive::CreateDirectory(const Path& path) const { |
| 85 | return FileUtil::CreateDir(mount_point + path.AsString()); | 97 | if (FileUtil::CreateDir(mount_point + path.AsString())) |
| 98 | return RESULT_SUCCESS; | ||
| 99 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description | ||
| 100 | ErrorSummary::Canceled, ErrorLevel::Status); | ||
| 86 | } | 101 | } |
| 87 | 102 | ||
| 88 | bool DiskArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const { | 103 | ResultCode DiskArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const { |
| 89 | return FileUtil::Rename(mount_point + src_path.AsString(), mount_point + dest_path.AsString()); | 104 | if (FileUtil::Rename(mount_point + src_path.AsString(), mount_point + dest_path.AsString())) |
| 105 | return RESULT_SUCCESS; | ||
| 106 | |||
| 107 | // TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't | ||
| 108 | // exist or similar. Verify. | ||
| 109 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description | ||
| 110 | ErrorSummary::NothingHappened, ErrorLevel::Status); | ||
| 90 | } | 111 | } |
| 91 | 112 | ||
| 92 | std::unique_ptr<DirectoryBackend> DiskArchive::OpenDirectory(const Path& path) const { | 113 | ResultVal<std::unique_ptr<DirectoryBackend>> DiskArchive::OpenDirectory(const Path& path) const { |
| 93 | LOG_DEBUG(Service_FS, "called path=%s", path.DebugStr().c_str()); | 114 | LOG_DEBUG(Service_FS, "called path=%s", path.DebugStr().c_str()); |
| 94 | auto directory = std::make_unique<DiskDirectory>(*this, path); | 115 | auto directory = std::make_unique<DiskDirectory>(*this, path); |
| 95 | if (!directory->Open()) | 116 | if (!directory->Open()) |
| 96 | return nullptr; | 117 | return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS, ErrorSummary::NotFound, |
| 97 | return std::move(directory); | 118 | ErrorLevel::Permanent); |
| 119 | return MakeResult<std::unique_ptr<DirectoryBackend>>(std::move(directory)); | ||
| 98 | } | 120 | } |
| 99 | 121 | ||
| 100 | u64 DiskArchive::GetFreeBytes() const { | 122 | u64 DiskArchive::GetFreeBytes() const { |
diff --git a/src/core/file_sys/disk_archive.h b/src/core/file_sys/disk_archive.h index 59ebb2002..0edd87954 100644 --- a/src/core/file_sys/disk_archive.h +++ b/src/core/file_sys/disk_archive.h | |||
| @@ -34,15 +34,15 @@ public: | |||
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | ResultVal<std::unique_ptr<FileBackend>> OpenFile(const Path& path, | 36 | ResultVal<std::unique_ptr<FileBackend>> OpenFile(const Path& path, |
| 37 | const Mode mode) const override; | 37 | const Mode& mode) const override; |
| 38 | ResultCode DeleteFile(const Path& path) const override; | 38 | ResultCode DeleteFile(const Path& path) const override; |
| 39 | bool RenameFile(const Path& src_path, const Path& dest_path) const override; | 39 | ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override; |
| 40 | bool DeleteDirectory(const Path& path) const override; | 40 | ResultCode DeleteDirectory(const Path& path) const override; |
| 41 | bool DeleteDirectoryRecursively(const Path& path) const override; | 41 | ResultCode DeleteDirectoryRecursively(const Path& path) const override; |
| 42 | ResultCode CreateFile(const Path& path, u64 size) const override; | 42 | ResultCode CreateFile(const Path& path, u64 size) const override; |
| 43 | bool CreateDirectory(const Path& path) const override; | 43 | ResultCode CreateDirectory(const Path& path) const override; |
| 44 | bool RenameDirectory(const Path& src_path, const Path& dest_path) const override; | 44 | ResultCode RenameDirectory(const Path& src_path, const Path& dest_path) const override; |
| 45 | std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const override; | 45 | ResultVal<std::unique_ptr<DirectoryBackend>> OpenDirectory(const Path& path) const override; |
| 46 | u64 GetFreeBytes() const override; | 46 | u64 GetFreeBytes() const override; |
| 47 | 47 | ||
| 48 | protected: | 48 | protected: |
diff --git a/src/core/file_sys/ivfc_archive.cpp b/src/core/file_sys/ivfc_archive.cpp index af59d296d..2735d2e3c 100644 --- a/src/core/file_sys/ivfc_archive.cpp +++ b/src/core/file_sys/ivfc_archive.cpp | |||
| @@ -18,7 +18,7 @@ std::string IVFCArchive::GetName() const { | |||
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | ResultVal<std::unique_ptr<FileBackend>> IVFCArchive::OpenFile(const Path& path, | 20 | ResultVal<std::unique_ptr<FileBackend>> IVFCArchive::OpenFile(const Path& path, |
| 21 | const Mode mode) const { | 21 | const Mode& mode) const { |
| 22 | return MakeResult<std::unique_ptr<FileBackend>>( | 22 | return MakeResult<std::unique_ptr<FileBackend>>( |
| 23 | std::make_unique<IVFCFile>(romfs_file, data_offset, data_size)); | 23 | std::make_unique<IVFCFile>(romfs_file, data_offset, data_size)); |
| 24 | } | 24 | } |
| @@ -31,22 +31,25 @@ ResultCode IVFCArchive::DeleteFile(const Path& path) const { | |||
| 31 | ErrorLevel::Status); | 31 | ErrorLevel::Status); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | bool IVFCArchive::RenameFile(const Path& src_path, const Path& dest_path) const { | 34 | ResultCode IVFCArchive::RenameFile(const Path& src_path, const Path& dest_path) const { |
| 35 | LOG_CRITICAL(Service_FS, "Attempted to rename a file within an IVFC archive (%s).", | 35 | LOG_CRITICAL(Service_FS, "Attempted to rename a file within an IVFC archive (%s).", |
| 36 | GetName().c_str()); | 36 | GetName().c_str()); |
| 37 | return false; | 37 | // TODO(wwylele): Use correct error code |
| 38 | return ResultCode(-1); | ||
| 38 | } | 39 | } |
| 39 | 40 | ||
| 40 | bool IVFCArchive::DeleteDirectory(const Path& path) const { | 41 | ResultCode IVFCArchive::DeleteDirectory(const Path& path) const { |
| 41 | LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an IVFC archive (%s).", | 42 | LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an IVFC archive (%s).", |
| 42 | GetName().c_str()); | 43 | GetName().c_str()); |
| 43 | return false; | 44 | // TODO(wwylele): Use correct error code |
| 45 | return ResultCode(-1); | ||
| 44 | } | 46 | } |
| 45 | 47 | ||
| 46 | bool IVFCArchive::DeleteDirectoryRecursively(const Path& path) const { | 48 | ResultCode IVFCArchive::DeleteDirectoryRecursively(const Path& path) const { |
| 47 | LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an IVFC archive (%s).", | 49 | LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an IVFC archive (%s).", |
| 48 | GetName().c_str()); | 50 | GetName().c_str()); |
| 49 | return false; | 51 | // TODO(wwylele): Use correct error code |
| 52 | return ResultCode(-1); | ||
| 50 | } | 53 | } |
| 51 | 54 | ||
| 52 | ResultCode IVFCArchive::CreateFile(const Path& path, u64 size) const { | 55 | ResultCode IVFCArchive::CreateFile(const Path& path, u64 size) const { |
| @@ -57,20 +60,22 @@ ResultCode IVFCArchive::CreateFile(const Path& path, u64 size) const { | |||
| 57 | ErrorLevel::Permanent); | 60 | ErrorLevel::Permanent); |
| 58 | } | 61 | } |
| 59 | 62 | ||
| 60 | bool IVFCArchive::CreateDirectory(const Path& path) const { | 63 | ResultCode IVFCArchive::CreateDirectory(const Path& path) const { |
| 61 | LOG_CRITICAL(Service_FS, "Attempted to create a directory in an IVFC archive (%s).", | 64 | LOG_CRITICAL(Service_FS, "Attempted to create a directory in an IVFC archive (%s).", |
| 62 | GetName().c_str()); | 65 | GetName().c_str()); |
| 63 | return false; | 66 | // TODO(wwylele): Use correct error code |
| 67 | return ResultCode(-1); | ||
| 64 | } | 68 | } |
| 65 | 69 | ||
| 66 | bool IVFCArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const { | 70 | ResultCode IVFCArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const { |
| 67 | LOG_CRITICAL(Service_FS, "Attempted to rename a file within an IVFC archive (%s).", | 71 | LOG_CRITICAL(Service_FS, "Attempted to rename a file within an IVFC archive (%s).", |
| 68 | GetName().c_str()); | 72 | GetName().c_str()); |
| 69 | return false; | 73 | // TODO(wwylele): Use correct error code |
| 74 | return ResultCode(-1); | ||
| 70 | } | 75 | } |
| 71 | 76 | ||
| 72 | std::unique_ptr<DirectoryBackend> IVFCArchive::OpenDirectory(const Path& path) const { | 77 | ResultVal<std::unique_ptr<DirectoryBackend>> IVFCArchive::OpenDirectory(const Path& path) const { |
| 73 | return std::make_unique<IVFCDirectory>(); | 78 | return MakeResult<std::unique_ptr<DirectoryBackend>>(std::make_unique<IVFCDirectory>()); |
| 74 | } | 79 | } |
| 75 | 80 | ||
| 76 | u64 IVFCArchive::GetFreeBytes() const { | 81 | u64 IVFCArchive::GetFreeBytes() const { |
diff --git a/src/core/file_sys/ivfc_archive.h b/src/core/file_sys/ivfc_archive.h index 2fbb3a568..af6297e1f 100644 --- a/src/core/file_sys/ivfc_archive.h +++ b/src/core/file_sys/ivfc_archive.h | |||
| @@ -33,15 +33,15 @@ public: | |||
| 33 | std::string GetName() const override; | 33 | std::string GetName() const override; |
| 34 | 34 | ||
| 35 | ResultVal<std::unique_ptr<FileBackend>> OpenFile(const Path& path, | 35 | ResultVal<std::unique_ptr<FileBackend>> OpenFile(const Path& path, |
| 36 | const Mode mode) const override; | 36 | const Mode& mode) const override; |
| 37 | ResultCode DeleteFile(const Path& path) const override; | 37 | ResultCode DeleteFile(const Path& path) const override; |
| 38 | bool RenameFile(const Path& src_path, const Path& dest_path) const override; | 38 | ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override; |
| 39 | bool DeleteDirectory(const Path& path) const override; | 39 | ResultCode DeleteDirectory(const Path& path) const override; |
| 40 | bool DeleteDirectoryRecursively(const Path& path) const override; | 40 | ResultCode DeleteDirectoryRecursively(const Path& path) const override; |
| 41 | ResultCode CreateFile(const Path& path, u64 size) const override; | 41 | ResultCode CreateFile(const Path& path, u64 size) const override; |
| 42 | bool CreateDirectory(const Path& path) const override; | 42 | ResultCode CreateDirectory(const Path& path) const override; |
| 43 | bool RenameDirectory(const Path& src_path, const Path& dest_path) const override; | 43 | ResultCode RenameDirectory(const Path& src_path, const Path& dest_path) const override; |
| 44 | std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const override; | 44 | ResultVal<std::unique_ptr<DirectoryBackend>> OpenDirectory(const Path& path) const override; |
| 45 | u64 GetFreeBytes() const override; | 45 | u64 GetFreeBytes() const override; |
| 46 | 46 | ||
| 47 | protected: | 47 | protected: |
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index 7f9696bfb..891d7bc84 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp | |||
| @@ -338,17 +338,11 @@ ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, | |||
| 338 | return ERR_INVALID_ARCHIVE_HANDLE; | 338 | return ERR_INVALID_ARCHIVE_HANDLE; |
| 339 | 339 | ||
| 340 | if (src_archive == dest_archive) { | 340 | if (src_archive == dest_archive) { |
| 341 | if (src_archive->RenameFile(src_path, dest_path)) | 341 | return src_archive->RenameFile(src_path, dest_path); |
| 342 | return RESULT_SUCCESS; | ||
| 343 | } else { | 342 | } else { |
| 344 | // TODO: Implement renaming across archives | 343 | // TODO: Implement renaming across archives |
| 345 | return UnimplementedFunction(ErrorModule::FS); | 344 | return UnimplementedFunction(ErrorModule::FS); |
| 346 | } | 345 | } |
| 347 | |||
| 348 | // TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't | ||
| 349 | // exist or similar. Verify. | ||
| 350 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description | ||
| 351 | ErrorSummary::NothingHappened, ErrorLevel::Status); | ||
| 352 | } | 346 | } |
| 353 | 347 | ||
| 354 | ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { | 348 | ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { |
| @@ -356,10 +350,7 @@ ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSy | |||
| 356 | if (archive == nullptr) | 350 | if (archive == nullptr) |
| 357 | return ERR_INVALID_ARCHIVE_HANDLE; | 351 | return ERR_INVALID_ARCHIVE_HANDLE; |
| 358 | 352 | ||
| 359 | if (archive->DeleteDirectory(path)) | 353 | return archive->DeleteDirectory(path); |
| 360 | return RESULT_SUCCESS; | ||
| 361 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description | ||
| 362 | ErrorSummary::Canceled, ErrorLevel::Status); | ||
| 363 | } | 354 | } |
| 364 | 355 | ||
| 365 | ResultCode DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle, | 356 | ResultCode DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle, |
| @@ -368,10 +359,7 @@ ResultCode DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle, | |||
| 368 | if (archive == nullptr) | 359 | if (archive == nullptr) |
| 369 | return ERR_INVALID_ARCHIVE_HANDLE; | 360 | return ERR_INVALID_ARCHIVE_HANDLE; |
| 370 | 361 | ||
| 371 | if (archive->DeleteDirectoryRecursively(path)) | 362 | return archive->DeleteDirectoryRecursively(path); |
| 372 | return RESULT_SUCCESS; | ||
| 373 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description | ||
| 374 | ErrorSummary::Canceled, ErrorLevel::Status); | ||
| 375 | } | 363 | } |
| 376 | 364 | ||
| 377 | ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, | 365 | ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, |
| @@ -388,10 +376,7 @@ ResultCode CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSy | |||
| 388 | if (archive == nullptr) | 376 | if (archive == nullptr) |
| 389 | return ERR_INVALID_ARCHIVE_HANDLE; | 377 | return ERR_INVALID_ARCHIVE_HANDLE; |
| 390 | 378 | ||
| 391 | if (archive->CreateDirectory(path)) | 379 | return archive->CreateDirectory(path); |
| 392 | return RESULT_SUCCESS; | ||
| 393 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description | ||
| 394 | ErrorSummary::Canceled, ErrorLevel::Status); | ||
| 395 | } | 380 | } |
| 396 | 381 | ||
| 397 | ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, | 382 | ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, |
| @@ -404,17 +389,11 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, | |||
| 404 | return ERR_INVALID_ARCHIVE_HANDLE; | 389 | return ERR_INVALID_ARCHIVE_HANDLE; |
| 405 | 390 | ||
| 406 | if (src_archive == dest_archive) { | 391 | if (src_archive == dest_archive) { |
| 407 | if (src_archive->RenameDirectory(src_path, dest_path)) | 392 | return src_archive->RenameDirectory(src_path, dest_path); |
| 408 | return RESULT_SUCCESS; | ||
| 409 | } else { | 393 | } else { |
| 410 | // TODO: Implement renaming across archives | 394 | // TODO: Implement renaming across archives |
| 411 | return UnimplementedFunction(ErrorModule::FS); | 395 | return UnimplementedFunction(ErrorModule::FS); |
| 412 | } | 396 | } |
| 413 | |||
| 414 | // TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't | ||
| 415 | // exist or similar. Verify. | ||
| 416 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description | ||
| 417 | ErrorSummary::NothingHappened, ErrorLevel::Status); | ||
| 418 | } | 397 | } |
| 419 | 398 | ||
| 420 | ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle archive_handle, | 399 | ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle archive_handle, |
| @@ -423,13 +402,11 @@ ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle a | |||
| 423 | if (archive == nullptr) | 402 | if (archive == nullptr) |
| 424 | return ERR_INVALID_ARCHIVE_HANDLE; | 403 | return ERR_INVALID_ARCHIVE_HANDLE; |
| 425 | 404 | ||
| 426 | std::unique_ptr<FileSys::DirectoryBackend> backend = archive->OpenDirectory(path); | 405 | auto backend = archive->OpenDirectory(path); |
| 427 | if (backend == nullptr) { | 406 | if (backend.Failed()) |
| 428 | return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS, ErrorSummary::NotFound, | 407 | return backend.Code(); |
| 429 | ErrorLevel::Permanent); | ||
| 430 | } | ||
| 431 | 408 | ||
| 432 | auto directory = Kernel::SharedPtr<Directory>(new Directory(std::move(backend), path)); | 409 | auto directory = Kernel::SharedPtr<Directory>(new Directory(backend.MoveFrom(), path)); |
| 433 | return MakeResult<Kernel::SharedPtr<Directory>>(std::move(directory)); | 410 | return MakeResult<Kernel::SharedPtr<Directory>>(std::move(directory)); |
| 434 | } | 411 | } |
| 435 | 412 | ||