From 4dd8a831bd5ea32108db837754289ab42a2fa6ca Mon Sep 17 00:00:00 2001 From: wwylele Date: Fri, 14 Oct 2016 15:29:09 +0800 Subject: FileSys: make Archive interfaces return error code and make the mode parameter a reference since it is a BitField union --- src/core/hle/service/fs/archive.cpp | 41 ++++++++----------------------------- 1 file changed, 9 insertions(+), 32 deletions(-) (limited to 'src/core/hle') 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, return ERR_INVALID_ARCHIVE_HANDLE; if (src_archive == dest_archive) { - if (src_archive->RenameFile(src_path, dest_path)) - return RESULT_SUCCESS; + return src_archive->RenameFile(src_path, dest_path); } else { // TODO: Implement renaming across archives return UnimplementedFunction(ErrorModule::FS); } - - // TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't - // exist or similar. Verify. - return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description - ErrorSummary::NothingHappened, ErrorLevel::Status); } ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { @@ -356,10 +350,7 @@ ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSy if (archive == nullptr) return ERR_INVALID_ARCHIVE_HANDLE; - if (archive->DeleteDirectory(path)) - return RESULT_SUCCESS; - return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description - ErrorSummary::Canceled, ErrorLevel::Status); + return archive->DeleteDirectory(path); } ResultCode DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle, @@ -368,10 +359,7 @@ ResultCode DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle, if (archive == nullptr) return ERR_INVALID_ARCHIVE_HANDLE; - if (archive->DeleteDirectoryRecursively(path)) - return RESULT_SUCCESS; - return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description - ErrorSummary::Canceled, ErrorLevel::Status); + return archive->DeleteDirectoryRecursively(path); } ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, @@ -388,10 +376,7 @@ ResultCode CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSy if (archive == nullptr) return ERR_INVALID_ARCHIVE_HANDLE; - if (archive->CreateDirectory(path)) - return RESULT_SUCCESS; - return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description - ErrorSummary::Canceled, ErrorLevel::Status); + return archive->CreateDirectory(path); } ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, @@ -404,17 +389,11 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, return ERR_INVALID_ARCHIVE_HANDLE; if (src_archive == dest_archive) { - if (src_archive->RenameDirectory(src_path, dest_path)) - return RESULT_SUCCESS; + return src_archive->RenameDirectory(src_path, dest_path); } else { // TODO: Implement renaming across archives return UnimplementedFunction(ErrorModule::FS); } - - // TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't - // exist or similar. Verify. - return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description - ErrorSummary::NothingHappened, ErrorLevel::Status); } ResultVal> OpenDirectoryFromArchive(ArchiveHandle archive_handle, @@ -423,13 +402,11 @@ ResultVal> OpenDirectoryFromArchive(ArchiveHandle a if (archive == nullptr) return ERR_INVALID_ARCHIVE_HANDLE; - std::unique_ptr backend = archive->OpenDirectory(path); - if (backend == nullptr) { - return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS, ErrorSummary::NotFound, - ErrorLevel::Permanent); - } + auto backend = archive->OpenDirectory(path); + if (backend.Failed()) + return backend.Code(); - auto directory = Kernel::SharedPtr(new Directory(std::move(backend), path)); + auto directory = Kernel::SharedPtr(new Directory(backend.MoveFrom(), path)); return MakeResult>(std::move(directory)); } -- cgit v1.2.3 From 7166fdc49072d987d04e681de4d9e1558ba75c63 Mon Sep 17 00:00:00 2001 From: wwylele Date: Mon, 17 Oct 2016 14:54:48 +0800 Subject: FileSys: add SaveDataArchive The error checking of SaveDataArchive is completely different from DiskArchive, so it has to be a new class instead of a subclass of DiskArchive. --- src/core/hle/result.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/core/hle') diff --git a/src/core/hle/result.h b/src/core/hle/result.h index 7f8d8e00d..8330894f2 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -20,15 +20,22 @@ enum class ErrorDescription : u32 { OS_InvalidBufferDescriptor = 48, WrongAddress = 53, FS_ArchiveNotMounted = 101, + FS_FileNotFound = 112, + FS_PathNotFound = 113, FS_NotFound = 120, + FS_FileAlreadyExists = 180, + FS_DirectoryAlreadyExists = 185, FS_AlreadyExists = 190, FS_InvalidOpenFlags = 230, + FS_DirectoryNotEmpty = 240, FS_NotAFile = 250, FS_NotFormatted = 340, ///< This is used by the FS service when creating a SaveData archive OutofRangeOrMisalignedAddress = 513, // TODO(purpasmart): Check if this name fits its actual usage GPU_FirstInitialization = 519, FS_InvalidPath = 702, + FS_UnsupportedOpenFlags = 760, + FS_UnexpectedFileOrDirectory = 770, InvalidSection = 1000, TooLarge = 1001, NotAuthorized = 1002, -- cgit v1.2.3 From a879984c06baf6c4185e376dd47258bfc108dec5 Mon Sep 17 00:00:00 2001 From: wwylele Date: Mon, 17 Oct 2016 20:23:34 +0800 Subject: FileSys: add ExtSaveDataArchive ExtSaveData is more similar to SaveData, so let it be a subclass of SaveData --- src/core/hle/result.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core/hle') diff --git a/src/core/hle/result.h b/src/core/hle/result.h index 8330894f2..a355f970a 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -34,6 +34,7 @@ enum class ErrorDescription : u32 { 513, // TODO(purpasmart): Check if this name fits its actual usage GPU_FirstInitialization = 519, FS_InvalidPath = 702, + FS_WriteBeyondEnd = 705, FS_UnsupportedOpenFlags = 760, FS_UnexpectedFileOrDirectory = 770, InvalidSection = 1000, -- cgit v1.2.3 From 098778369962f8ec5eba6ccc91b2846c72cb0005 Mon Sep 17 00:00:00 2001 From: wwylele Date: Tue, 18 Oct 2016 17:27:51 +0800 Subject: FileSys: add SDMCWriteOnlyArchive --- src/core/hle/result.h | 1 + src/core/hle/service/fs/archive.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) (limited to 'src/core/hle') diff --git a/src/core/hle/result.h b/src/core/hle/result.h index a355f970a..f7356f9d8 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -33,6 +33,7 @@ enum class ErrorDescription : u32 { OutofRangeOrMisalignedAddress = 513, // TODO(purpasmart): Check if this name fits its actual usage GPU_FirstInitialization = 519, + FS_InvalidReadFlag = 700, FS_InvalidPath = 702, FS_WriteBeyondEnd = 705, FS_UnsupportedOpenFlags = 760, diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index 891d7bc84..62cf2c249 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp @@ -18,6 +18,7 @@ #include "core/file_sys/archive_savedata.h" #include "core/file_sys/archive_savedatacheck.h" #include "core/file_sys/archive_sdmc.h" +#include "core/file_sys/archive_sdmcwriteonly.h" #include "core/file_sys/archive_systemsavedata.h" #include "core/file_sys/directory_backend.h" #include "core/file_sys/file_backend.h" @@ -526,6 +527,13 @@ void RegisterArchiveTypes() { LOG_ERROR(Service_FS, "Can't instantiate SDMC archive with path %s", sdmc_directory.c_str()); + auto sdmcwo_factory = std::make_unique(sdmc_directory); + if (sdmcwo_factory->Initialize()) + RegisterArchiveType(std::move(sdmcwo_factory), ArchiveIdCode::SDMCWriteOnly); + else + LOG_ERROR(Service_FS, "Can't instantiate SDMCWriteOnly archive with path %s", + sdmc_directory.c_str()); + // Create the SaveData archive auto savedata_factory = std::make_unique(sdmc_directory); RegisterArchiveType(std::move(savedata_factory), ArchiveIdCode::SaveData); -- cgit v1.2.3 From 5c6e13a171cd5952732895bba645f375ae38d775 Mon Sep 17 00:00:00 2001 From: wwylele Date: Thu, 20 Oct 2016 09:43:43 +0800 Subject: PTM & CFG: use the correct path and error code according to the new FileSys policy --- src/core/hle/service/cfg/cfg.cpp | 9 +++++---- src/core/hle/service/ptm/ptm.cpp | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/core/hle') diff --git a/src/core/hle/service/cfg/cfg.cpp b/src/core/hle/service/cfg/cfg.cpp index 24eee6903..849dab707 100644 --- a/src/core/hle/service/cfg/cfg.cpp +++ b/src/core/hle/service/cfg/cfg.cpp @@ -359,7 +359,7 @@ ResultCode CreateConfigInfoBlk(u32 block_id, u16 size, u16 flags, const void* da } ResultCode DeleteConfigNANDSaveFile() { - FileSys::Path path("config"); + FileSys::Path path("/config"); return Service::FS::DeleteFileFromArchive(cfg_system_save_data_archive, path); } @@ -368,7 +368,7 @@ ResultCode UpdateConfigNANDSavegame() { mode.write_flag.Assign(1); mode.create_flag.Assign(1); - FileSys::Path path("config"); + FileSys::Path path("/config"); auto config_result = Service::FS::OpenFileFromArchive(cfg_system_save_data_archive, path, mode); ASSERT_MSG(config_result.Succeeded(), "could not open file"); @@ -382,8 +382,9 @@ ResultCode UpdateConfigNANDSavegame() { ResultCode FormatConfig() { ResultCode res = DeleteConfigNANDSaveFile(); // The delete command fails if the file doesn't exist, so we have to check that too - if (!res.IsSuccess() && res.description != ErrorDescription::FS_NotFound) + if (!res.IsSuccess() && res.description != ErrorDescription::FS_FileNotFound) { return res; + } // Delete the old data cfg_config_file_buffer.fill(0); // Create the header @@ -504,7 +505,7 @@ ResultCode LoadConfigNANDSaveFile() { cfg_system_save_data_archive = *archive_result; - FileSys::Path config_path("config"); + FileSys::Path config_path("/config"); FileSys::Mode open_mode = {}; open_mode.read_flag.Assign(1); diff --git a/src/core/hle/service/ptm/ptm.cpp b/src/core/hle/service/ptm/ptm.cpp index 6e6b63329..cc859c14c 100644 --- a/src/core/hle/service/ptm/ptm.cpp +++ b/src/core/hle/service/ptm/ptm.cpp @@ -128,7 +128,7 @@ void Init() { Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path); ASSERT_MSG(archive_result.Succeeded(), "Could not open the PTM SharedExtSaveData archive!"); - FileSys::Path gamecoin_path("gamecoin.dat"); + FileSys::Path gamecoin_path("/gamecoin.dat"); FileSys::Mode open_mode = {}; open_mode.write_flag.Assign(1); open_mode.create_flag.Assign(1); -- cgit v1.2.3 From d7d6975af0971f5a07d489bdef522ca121bb30ec Mon Sep 17 00:00:00 2001 From: wwylele Date: Fri, 21 Oct 2016 22:10:55 +0800 Subject: FileSys: rename SaveDataCheck archive to NCCH archive According to the observation from game and 3dbrew "Used for accessing general NCCH data" --- src/core/hle/service/fs/archive.cpp | 9 ++++----- src/core/hle/service/fs/archive.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'src/core/hle') diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index 62cf2c249..4c29784e8 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp @@ -15,8 +15,8 @@ #include "common/logging/log.h" #include "core/file_sys/archive_backend.h" #include "core/file_sys/archive_extsavedata.h" +#include "core/file_sys/archive_ncch.h" #include "core/file_sys/archive_savedata.h" -#include "core/file_sys/archive_savedatacheck.h" #include "core/file_sys/archive_sdmc.h" #include "core/file_sys/archive_sdmcwriteonly.h" #include "core/file_sys/archive_systemsavedata.h" @@ -554,10 +554,9 @@ void RegisterArchiveTypes() { LOG_ERROR(Service_FS, "Can't instantiate SharedExtSaveData archive with path %s", sharedextsavedata_factory->GetMountPoint().c_str()); - // Create the SaveDataCheck archive, basically a small variation of the RomFS archive - auto savedatacheck_factory = - std::make_unique(nand_directory); - RegisterArchiveType(std::move(savedatacheck_factory), ArchiveIdCode::SaveDataCheck); + // Create the NCCH archive, basically a small variation of the RomFS archive + auto savedatacheck_factory = std::make_unique(nand_directory); + RegisterArchiveType(std::move(savedatacheck_factory), ArchiveIdCode::NCCH); auto systemsavedata_factory = std::make_unique(nand_directory); diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h index 41a76285c..21ed9717b 100644 --- a/src/core/hle/service/fs/archive.h +++ b/src/core/hle/service/fs/archive.h @@ -33,7 +33,7 @@ enum class ArchiveIdCode : u32 { SystemSaveData = 0x00000008, SDMC = 0x00000009, SDMCWriteOnly = 0x0000000A, - SaveDataCheck = 0x2345678A, + NCCH = 0x2345678A, }; /// Media types for the archives -- cgit v1.2.3