From d26c6b3212ed36970410814593ee5ec082b1d95a Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 28 Dec 2015 13:51:44 -0500 Subject: HLE/FS: Implemented GetFormatInfo Format information is currently only implemented for the ExtSaveData, SharedExtSaveData and SaveData archives, the information is stored in a file alongside the root folder of the archive. --- src/core/hle/service/fs/archive.cpp | 48 +++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 26 deletions(-) (limited to 'src/core/hle/service/fs/archive.cpp') diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index b034de8f1..63381250a 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp @@ -421,49 +421,45 @@ ResultVal GetFreeBytesInArchive(ArchiveHandle archive_handle) { return MakeResult(archive->GetFreeBytes()); } -ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::Path& path) { +ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::ArchiveFormatInfo& format_info, const FileSys::Path& path) { auto archive_itr = id_code_map.find(id_code); if (archive_itr == id_code_map.end()) { return UnimplementedFunction(ErrorModule::FS); // TODO(Subv): Find the right error } - return archive_itr->second->Format(path); + return archive_itr->second->Format(path, format_info); } -ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low, VAddr icon_buffer, u32 icon_size) { +ResultVal GetArchiveFormatInfo(ArchiveIdCode id_code, FileSys::Path& archive_path) { + auto archive = id_code_map.find(id_code); + if (archive == id_code_map.end()) { + return UnimplementedFunction(ErrorModule::FS); // TODO(Subv): Find the right error + } + + return archive->second->GetFormatInfo(archive_path); +} + +ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low, VAddr icon_buffer, u32 icon_size, const FileSys::ArchiveFormatInfo& format_info) { // Construct the binary path to the archive first FileSys::Path path = FileSys::ConstructExtDataBinaryPath(static_cast(media_type), high, low); - std::string media_type_directory; - if (media_type == MediaType::NAND) { - media_type_directory = FileUtil::GetUserPath(D_NAND_IDX); - } else if (media_type == MediaType::SDMC) { - media_type_directory = FileUtil::GetUserPath(D_SDMC_IDX); - } else { - LOG_ERROR(Service_FS, "Unsupported media type %u", media_type); - return ResultCode(-1); // TODO(Subv): Find the right error code + auto archive = id_code_map.find(media_type == MediaType::NAND ? ArchiveIdCode::SharedExtSaveData : ArchiveIdCode::ExtSaveData); + + if (archive == id_code_map.end()) { + return UnimplementedFunction(ErrorModule::FS); // TODO(Subv): Find the right error } - std::string base_path = FileSys::GetExtDataContainerPath(media_type_directory, media_type == MediaType::NAND); - std::string game_path = FileSys::GetExtSaveDataPath(base_path, path); - // These two folders are always created with the ExtSaveData - std::string user_path = game_path + "user/"; - std::string boss_path = game_path + "boss/"; - if (!FileUtil::CreateFullPath(user_path)) - return ResultCode(-1); // TODO(Subv): Find the right error code - if (!FileUtil::CreateFullPath(boss_path)) - return ResultCode(-1); // TODO(Subv): Find the right error code + auto ext_savedata = static_cast(archive->second.get()); + + ResultCode result = ext_savedata->Format(path, format_info); + if (result.IsError()) + return result; u8* smdh_icon = Memory::GetPointer(icon_buffer); if (!smdh_icon) return ResultCode(-1); // TODO(Subv): Find the right error code - // Create the icon - FileUtil::IOFile icon_file(game_path + "icon", "wb+"); - if (!icon_file.IsGood()) - return ResultCode(-1); // TODO(Subv): Find the right error code - - icon_file.WriteBytes(smdh_icon, icon_size); + ext_savedata->WriteIcon(path, smdh_icon, icon_size); return RESULT_SUCCESS; } -- cgit v1.2.3