diff options
author | Subv <subv2112@gmail.com> | 2015-12-28 15:59:27 +0100 |
---|---|---|
committer | Subv <subv2112@gmail.com> | 2016-03-20 20:28:14 +0100 |
commit | 09b0564c75c3da41eaf15dcb847831c11f4c27b9 (patch) | |
tree | dce86c99034cd11bbba6b599389c72e827fedbaa /src/core/file_sys | |
parent | HLE/FS: Corrected the error codes for CreateFile (diff) | |
download | yuzu-09b0564c75c3da41eaf15dcb847831c11f4c27b9.tar yuzu-09b0564c75c3da41eaf15dcb847831c11f4c27b9.tar.gz yuzu-09b0564c75c3da41eaf15dcb847831c11f4c27b9.tar.bz2 yuzu-09b0564c75c3da41eaf15dcb847831c11f4c27b9.tar.lz yuzu-09b0564c75c3da41eaf15dcb847831c11f4c27b9.tar.xz yuzu-09b0564c75c3da41eaf15dcb847831c11f4c27b9.tar.zst yuzu-09b0564c75c3da41eaf15dcb847831c11f4c27b9.zip |
Diffstat (limited to 'src/core/file_sys')
-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 |
5 files changed, 21 insertions, 8 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: /** * Delete a file specified by its path * @param path Path relative to the archive - * @return Whether the file could be deleted + * @return Result of the operation */ - virtual bool DeleteFile(const Path& path) const = 0; + virtual ResultCode DeleteFile(const Path& path) const = 0; /** * 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 return std::move(file); } -bool DiskArchive::DeleteFile(const Path& path) const { - return FileUtil::Delete(mount_point + path.AsString()); +ResultCode DiskArchive::DeleteFile(const Path& path) const { + std::string file_path = mount_point + path.AsString(); + + if (FileUtil::IsDirectory(file_path)) + return ResultCode(ErrorDescription::FS_NotAFile, ErrorModule::FS, ErrorSummary::Canceled, ErrorLevel::Status); + + if (!FileUtil::Exists(file_path)) + return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS, ErrorSummary::NotFound, ErrorLevel::Status); + + if (FileUtil::Delete(file_path)) + return RESULT_SUCCESS; + + return ResultCode(ErrorDescription::FS_NotAFile, ErrorModule::FS, ErrorSummary::Canceled, ErrorLevel::Status); } 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: virtual std::string GetName() const override { return "DiskArchive: " + mount_point; } std::unique_ptr<FileBackend> OpenFile(const Path& path, const Mode mode) const override; - bool DeleteFile(const Path& path) const override; + ResultCode DeleteFile(const Path& path) const override; bool RenameFile(const Path& src_path, const Path& dest_path) const override; bool DeleteDirectory(const Path& path) const override; 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 return Common::make_unique<IVFCFile>(romfs_file, data_offset, data_size); } -bool IVFCArchive::DeleteFile(const Path& path) const { +ResultCode IVFCArchive::DeleteFile(const Path& path) const { LOG_CRITICAL(Service_FS, "Attempted to delete a file from an IVFC archive (%s).", GetName().c_str()); - return false; + // TODO(Subv): Verify error code + return ResultCode(ErrorDescription::NoData, ErrorModule::FS, + ErrorSummary::Canceled, ErrorLevel::Status); } 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: std::string GetName() const override; std::unique_ptr<FileBackend> OpenFile(const Path& path, const Mode mode) const override; - bool DeleteFile(const Path& path) const override; + ResultCode DeleteFile(const Path& path) const override; bool RenameFile(const Path& src_path, const Path& dest_path) const override; bool DeleteDirectory(const Path& path) const override; ResultCode CreateFile(const Path& path, u64 size) const override; |