diff options
| author | 2015-12-28 09:59:27 -0500 | |
|---|---|---|
| committer | 2016-03-20 14:28:14 -0500 | |
| commit | 09b0564c75c3da41eaf15dcb847831c11f4c27b9 (patch) | |
| tree | dce86c99034cd11bbba6b599389c72e827fedbaa /src/core | |
| parent | HLE/FS: Corrected the error codes for CreateFile (diff) | |
| download | yuzu-09b0564c75c3da41eaf15dcb847831c11f4c27b9.tar.gz yuzu-09b0564c75c3da41eaf15dcb847831c11f4c27b9.tar.xz yuzu-09b0564c75c3da41eaf15dcb847831c11f4c27b9.zip | |
HLE/FS: Corrected the error codes for DeleteFile
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/file_sys/archive_backend.h | 4 | ||||
| -rw-r--r-- | src/core/file_sys/disk_archive.cpp | 15 | ||||
| -rw-r--r-- | src/core/file_sys/disk_archive.h | 2 | ||||
| -rw-r--r-- | src/core/file_sys/ivfc_archive.cpp | 6 | ||||
| -rw-r--r-- | src/core/file_sys/ivfc_archive.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/fs/archive.cpp | 5 |
6 files changed, 22 insertions, 12 deletions
diff --git a/src/core/file_sys/archive_backend.h b/src/core/file_sys/archive_backend.h index 152c8201c..c5da9bd6f 100644 --- a/src/core/file_sys/archive_backend.h +++ b/src/core/file_sys/archive_backend.h | |||
| @@ -83,9 +83,9 @@ public: | |||
| 83 | /** | 83 | /** |
| 84 | * Delete a file specified by its path | 84 | * Delete a file specified by its path |
| 85 | * @param path Path relative to the archive | 85 | * @param path Path relative to the archive |
| 86 | * @return Whether the file could be deleted | 86 | * @return Result of the operation |
| 87 | */ | 87 | */ |
| 88 | virtual bool DeleteFile(const Path& path) const = 0; | 88 | virtual ResultCode DeleteFile(const Path& path) const = 0; |
| 89 | 89 | ||
| 90 | /** | 90 | /** |
| 91 | * Rename a File specified by its path | 91 | * Rename a File specified by its path |
diff --git a/src/core/file_sys/disk_archive.cpp b/src/core/file_sys/disk_archive.cpp index 5c68e944f..0c55a4863 100644 --- a/src/core/file_sys/disk_archive.cpp +++ b/src/core/file_sys/disk_archive.cpp | |||
| @@ -25,8 +25,19 @@ std::unique_ptr<FileBackend> DiskArchive::OpenFile(const Path& path, const Mode | |||
| 25 | return std::move(file); | 25 | return std::move(file); |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | bool DiskArchive::DeleteFile(const Path& path) const { | 28 | ResultCode DiskArchive::DeleteFile(const Path& path) const { |
| 29 | return FileUtil::Delete(mount_point + path.AsString()); | 29 | std::string file_path = mount_point + path.AsString(); |
| 30 | |||
| 31 | if (FileUtil::IsDirectory(file_path)) | ||
| 32 | return ResultCode(ErrorDescription::FS_NotAFile, ErrorModule::FS, ErrorSummary::Canceled, ErrorLevel::Status); | ||
| 33 | |||
| 34 | if (!FileUtil::Exists(file_path)) | ||
| 35 | return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS, ErrorSummary::NotFound, ErrorLevel::Status); | ||
| 36 | |||
| 37 | if (FileUtil::Delete(file_path)) | ||
| 38 | return RESULT_SUCCESS; | ||
| 39 | |||
| 40 | return ResultCode(ErrorDescription::FS_NotAFile, ErrorModule::FS, ErrorSummary::Canceled, ErrorLevel::Status); | ||
| 30 | } | 41 | } |
| 31 | 42 | ||
| 32 | bool DiskArchive::RenameFile(const Path& src_path, const Path& dest_path) const { | 43 | bool DiskArchive::RenameFile(const Path& src_path, const Path& dest_path) const { |
diff --git a/src/core/file_sys/disk_archive.h b/src/core/file_sys/disk_archive.h index 1bdbc2698..c0a3d3f7b 100644 --- a/src/core/file_sys/disk_archive.h +++ b/src/core/file_sys/disk_archive.h | |||
| @@ -34,7 +34,7 @@ public: | |||
| 34 | virtual std::string GetName() const override { return "DiskArchive: " + mount_point; } | 34 | virtual std::string GetName() const override { return "DiskArchive: " + mount_point; } |
| 35 | 35 | ||
| 36 | std::unique_ptr<FileBackend> OpenFile(const Path& path, const Mode mode) const override; | 36 | std::unique_ptr<FileBackend> OpenFile(const Path& path, const Mode mode) const override; |
| 37 | bool 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 | bool RenameFile(const Path& src_path, const Path& dest_path) const override; |
| 39 | bool DeleteDirectory(const Path& path) const override; | 39 | bool DeleteDirectory(const Path& path) const override; |
| 40 | ResultCode CreateFile(const Path& path, u64 size) const override; | 40 | ResultCode CreateFile(const Path& path, u64 size) const override; |
diff --git a/src/core/file_sys/ivfc_archive.cpp b/src/core/file_sys/ivfc_archive.cpp index 5325afb58..f2f96ef1a 100644 --- a/src/core/file_sys/ivfc_archive.cpp +++ b/src/core/file_sys/ivfc_archive.cpp | |||
| @@ -24,9 +24,11 @@ std::unique_ptr<FileBackend> IVFCArchive::OpenFile(const Path& path, const Mode | |||
| 24 | return Common::make_unique<IVFCFile>(romfs_file, data_offset, data_size); | 24 | return Common::make_unique<IVFCFile>(romfs_file, data_offset, data_size); |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | bool IVFCArchive::DeleteFile(const Path& path) const { | 27 | ResultCode IVFCArchive::DeleteFile(const Path& path) const { |
| 28 | LOG_CRITICAL(Service_FS, "Attempted to delete a file from an IVFC archive (%s).", GetName().c_str()); | 28 | LOG_CRITICAL(Service_FS, "Attempted to delete a file from an IVFC archive (%s).", GetName().c_str()); |
| 29 | return false; | 29 | // TODO(Subv): Verify error code |
| 30 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, | ||
| 31 | ErrorSummary::Canceled, ErrorLevel::Status); | ||
| 30 | } | 32 | } |
| 31 | 33 | ||
| 32 | bool IVFCArchive::RenameFile(const Path& src_path, const Path& dest_path) const { | 34 | bool IVFCArchive::RenameFile(const Path& src_path, const Path& dest_path) const { |
diff --git a/src/core/file_sys/ivfc_archive.h b/src/core/file_sys/ivfc_archive.h index 2a4e4def3..5d3a5b61e 100644 --- a/src/core/file_sys/ivfc_archive.h +++ b/src/core/file_sys/ivfc_archive.h | |||
| @@ -35,7 +35,7 @@ public: | |||
| 35 | std::string GetName() const override; | 35 | std::string GetName() const override; |
| 36 | 36 | ||
| 37 | std::unique_ptr<FileBackend> OpenFile(const Path& path, const Mode mode) const override; | 37 | std::unique_ptr<FileBackend> OpenFile(const Path& path, const Mode mode) const override; |
| 38 | bool 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 | bool RenameFile(const Path& src_path, const Path& dest_path) const override; |
| 40 | bool DeleteDirectory(const Path& path) const override; | 40 | bool DeleteDirectory(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; |
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index 57fc2f44d..cb98fa7aa 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp | |||
| @@ -309,10 +309,7 @@ ResultCode DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Pa | |||
| 309 | if (archive == nullptr) | 309 | if (archive == nullptr) |
| 310 | return ERR_INVALID_HANDLE; | 310 | return ERR_INVALID_HANDLE; |
| 311 | 311 | ||
| 312 | if (archive->DeleteFile(path)) | 312 | return archive->DeleteFile(path); |
| 313 | return RESULT_SUCCESS; | ||
| 314 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description | ||
| 315 | ErrorSummary::Canceled, ErrorLevel::Status); | ||
| 316 | } | 313 | } |
| 317 | 314 | ||
| 318 | ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, const FileSys::Path& src_path, | 315 | ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, const FileSys::Path& src_path, |