diff --git a/src/core/file_sys/archive_extsavedata.cpp b/src/core/file_sys/archive_extsavedata.cpp index 7df245958..ed9a2469d 100644 --- a/src/core/file_sys/archive_extsavedata.cpp +++ b/src/core/file_sys/archive_extsavedata.cpp @@ -289,8 +289,13 @@ ResultVal> ArchiveFactory_ExtSaveData::Open(cons Result ArchiveFactory_ExtSaveData::FormatAsExtData(const Path& path, const FileSys::ArchiveFormatInfo& format_info, u8 unknown, u64 program_id, u64 total_size, - std::span icon) { + std::optional> icon) { if (IsUsingArtic()) { + if (!icon.has_value()) { + LOG_ERROR(Service_FS, "No icon provided while using Artic Base"); + return ResultUnknown; + } + ExtSaveDataArchivePath 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_files); req.AddParameterU64(total_size); - req.AddParameterBuffer(icon.data(), icon.size()); + req.AddParameterBuffer(icon->data(), icon->size()); return ArticArchive::RespResult(artic_client->Send(req)); } else { @@ -330,10 +335,11 @@ Result ArchiveFactory_ExtSaveData::FormatAsExtData(const Path& path, file.WriteBytes(&format_info, sizeof(format_info)); - FileUtil::IOFile icon_file(FileSys::GetExtSaveDataPath(GetMountPoint(), path) + "icon", - "wb"); - icon_file.WriteBytes(icon.data(), icon.size()); - + if (icon.has_value()) { + FileUtil::IOFile icon_file(FileSys::GetExtSaveDataPath(GetMountPoint(), path) + "icon", + "wb"); + icon_file.WriteBytes(icon->data(), icon->size()); + } return ResultSuccess; } } diff --git a/src/core/file_sys/archive_extsavedata.h b/src/core/file_sys/archive_extsavedata.h index 8377a4213..3bbfbdd91 100644 --- a/src/core/file_sys/archive_extsavedata.h +++ b/src/core/file_sys/archive_extsavedata.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include #include #include @@ -51,7 +52,8 @@ public: }; Result FormatAsExtData(const Path& path, const FileSys::ArchiveFormatInfo& format_info, - u8 unknown, u64 program_id, u64 total_size, std::span icon); + u8 unknown, u64 program_id, u64 total_size, + std::optional> icon); Result DeleteExtData(Service::FS::MediaType media_type, u8 unknown, u32 high, u32 low); diff --git a/src/core/hle/service/ptm/ptm.cpp b/src/core/hle/service/ptm/ptm.cpp index b3ea47dff..da638dae8 100644 --- a/src/core/hle/service/ptm/ptm.cpp +++ b/src/core/hle/service/ptm/ptm.cpp @@ -158,7 +158,8 @@ static void WriteGameCoinData(GameCoin gamecoin_data) { // If the archive didn't exist, create the files inside if (archive_result.Code() == FileSys::ResultNotFormatted) { // 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 archive = extdata_archive_factory.Open(archive_path, 0).Unwrap(); // Create the game coin file