aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/hle/service/fs/archive.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/service/fs/archive.cpp')
-rw-r--r--src/core/hle/service/fs/archive.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp
index 6d4a9c7c..4e275cb1 100644
--- a/src/core/hle/service/fs/archive.cpp
+++ b/src/core/hle/service/fs/archive.cpp
@@ -254,7 +254,7 @@ ResultVal<ArchiveHandle> OpenArchive(ArchiveIdCode id_code, FileSys::Path& archi
CASCADE_RESULT(std::unique_ptr<ArchiveBackend> res, itr->second->Open(archive_path));
- // This should never even happen in the first place with 64-bit handles,
+ // This should never even happen in the first place with 64-bit handles,
while (handle_map.count(next_handle) != 0) {
++next_handle;
}
@@ -406,7 +406,7 @@ ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::Path& path) {
return archive_itr->second->Format(path);
}
-ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low) {
+ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low, VAddr icon_buffer, u32 icon_size) {
// Construct the binary path to the archive first
FileSys::Path path = FileSys::ConstructExtDataBinaryPath(static_cast<u32>(media_type), high, low);
@@ -421,9 +421,25 @@ ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low) {
}
std::string base_path = FileSys::GetExtDataContainerPath(media_type_directory, media_type == MediaType::NAND);
- std::string extsavedata_path = FileSys::GetExtSaveDataPath(base_path, path);
- if (!FileUtil::CreateFullPath(extsavedata_path))
+ 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
+
+ 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);
return RESULT_SUCCESS;
}
@@ -441,6 +457,7 @@ ResultCode DeleteExtSaveData(MediaType media_type, u32 high, u32 low) {
return ResultCode(-1); // TODO(Subv): Find the right error code
}
+ // Delete all directories (/user, /boss) and the icon file.
std::string base_path = FileSys::GetExtDataContainerPath(media_type_directory, media_type == MediaType::NAND);
std::string extsavedata_path = FileSys::GetExtSaveDataPath(base_path, path);
if (!FileUtil::DeleteDirRecursively(extsavedata_path))
@@ -488,7 +505,7 @@ void ArchiveInit() {
RegisterArchiveType(std::move(sdmc_factory), ArchiveIdCode::SDMC);
else
LOG_ERROR(Service_FS, "Can't instantiate SDMC archive with path %s", sdmc_directory.c_str());
-
+
// Create the SaveData archive
auto savedata_factory = Common::make_unique<FileSys::ArchiveFactory_SaveData>(sdmc_directory);
RegisterArchiveType(std::move(savedata_factory), ArchiveIdCode::SaveData);
@@ -503,7 +520,7 @@ void ArchiveInit() {
if (sharedextsavedata_factory->Initialize())
RegisterArchiveType(std::move(sharedextsavedata_factory), ArchiveIdCode::SharedExtSaveData);
else
- LOG_ERROR(Service_FS, "Can't instantiate SharedExtSaveData archive with path %s",
+ 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