mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-14 00:28:20 -05:00
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.
This commit is contained in:
@ -421,49 +421,45 @@ ResultVal<u64> GetFreeBytesInArchive(ArchiveHandle archive_handle) {
|
||||
return MakeResult<u64>(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<FileSys::ArchiveFormatInfo> 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<u32>(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<FileSys::ArchiveFactory_ExtSaveData*>(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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user