VERY experimental Nintendo Switch 2 emulator
C++
HLE/FS: Corrected the error codes for DeleteFile
Subve248331abc87
diff --git a/src/core/file_sys/archive_backend.h b/src/core/file_sys/archive_backend.hindex 152c8201c2..c5da9bd6f5 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 pathdiff --git a/src/core/file_sys/disk_archive.cpp b/src/core/file_sys/disk_archive.cppindex 5c68e944f7..0c55a48636 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 Modereturn 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.hindex 1bdbc26980..c0a3d3f7be 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.cppindex 5325afb583..f2f96ef1a6 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 Modereturn 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.hindex 2a4e4def31..5d3a5b61e6 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;diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cppindex 57fc2f44dd..cb98fa7aab 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::Paif (archive == nullptr)return ERR_INVALID_HANDLE;- if (archive->DeleteFile(path))- return RESULT_SUCCESS;- return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description- ErrorSummary::Canceled, ErrorLevel::Status);+ return archive->DeleteFile(path);}ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, const FileSys::Path& src_path,