Fix PTM ext data creation after Artic Base changes

This commit is contained in:
PabloMK7 2024-05-13 10:54:52 +02:00 committed by OpenSauce04
parent c9932b65b9
commit b1262f4768
3 changed files with 17 additions and 8 deletions

View File

@ -289,8 +289,13 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_ExtSaveData::Open(cons
Result ArchiveFactory_ExtSaveData::FormatAsExtData(const Path& path, Result ArchiveFactory_ExtSaveData::FormatAsExtData(const Path& path,
const FileSys::ArchiveFormatInfo& format_info, const FileSys::ArchiveFormatInfo& format_info,
u8 unknown, u64 program_id, u64 total_size, u8 unknown, u64 program_id, u64 total_size,
std::span<const u8> icon) { std::optional<std::span<const u8>> icon) {
if (IsUsingArtic()) { if (IsUsingArtic()) {
if (!icon.has_value()) {
LOG_ERROR(Service_FS, "No icon provided while using Artic Base");
return ResultUnknown;
}
ExtSaveDataArchivePath path_data; ExtSaveDataArchivePath path_data;
std::memcpy(&path_data, path.AsBinary().data(), sizeof(path_data)); std::memcpy(&path_data, path.AsBinary().data(), sizeof(path_data));
@ -307,7 +312,7 @@ Result ArchiveFactory_ExtSaveData::FormatAsExtData(const Path& path,
req.AddParameterU32(format_info.number_directories); req.AddParameterU32(format_info.number_directories);
req.AddParameterU32(format_info.number_files); req.AddParameterU32(format_info.number_files);
req.AddParameterU64(total_size); req.AddParameterU64(total_size);
req.AddParameterBuffer(icon.data(), icon.size()); req.AddParameterBuffer(icon->data(), icon->size());
return ArticArchive::RespResult(artic_client->Send(req)); return ArticArchive::RespResult(artic_client->Send(req));
} else { } else {
@ -330,10 +335,11 @@ Result ArchiveFactory_ExtSaveData::FormatAsExtData(const Path& path,
file.WriteBytes(&format_info, sizeof(format_info)); file.WriteBytes(&format_info, sizeof(format_info));
FileUtil::IOFile icon_file(FileSys::GetExtSaveDataPath(GetMountPoint(), path) + "icon", if (icon.has_value()) {
"wb"); FileUtil::IOFile icon_file(FileSys::GetExtSaveDataPath(GetMountPoint(), path) + "icon",
icon_file.WriteBytes(icon.data(), icon.size()); "wb");
icon_file.WriteBytes(icon->data(), icon->size());
}
return ResultSuccess; return ResultSuccess;
} }
} }

View File

@ -5,6 +5,7 @@
#pragma once #pragma once
#include <memory> #include <memory>
#include <optional>
#include <span> #include <span>
#include <string> #include <string>
#include <boost/serialization/export.hpp> #include <boost/serialization/export.hpp>
@ -51,7 +52,8 @@ public:
}; };
Result FormatAsExtData(const Path& path, const FileSys::ArchiveFormatInfo& format_info, Result FormatAsExtData(const Path& path, const FileSys::ArchiveFormatInfo& format_info,
u8 unknown, u64 program_id, u64 total_size, std::span<const u8> icon); u8 unknown, u64 program_id, u64 total_size,
std::optional<std::span<const u8>> icon);
Result DeleteExtData(Service::FS::MediaType media_type, u8 unknown, u32 high, u32 low); Result DeleteExtData(Service::FS::MediaType media_type, u8 unknown, u32 high, u32 low);

View File

@ -158,7 +158,8 @@ static void WriteGameCoinData(GameCoin gamecoin_data) {
// If the archive didn't exist, create the files inside // If the archive didn't exist, create the files inside
if (archive_result.Code() == FileSys::ResultNotFormatted) { if (archive_result.Code() == FileSys::ResultNotFormatted) {
// Format the archive to create the directories // Format the archive to create the directories
extdata_archive_factory.Format(archive_path, FileSys::ArchiveFormatInfo(), 0, 0, 0); extdata_archive_factory.FormatAsExtData(archive_path, FileSys::ArchiveFormatInfo(), 0, 0, 0,
std::nullopt);
// Open it again to get a valid archive now that the folder exists // Open it again to get a valid archive now that the folder exists
archive = extdata_archive_factory.Open(archive_path, 0).Unwrap(); archive = extdata_archive_factory.Open(archive_path, 0).Unwrap();
// Create the game coin file // Create the game coin file