diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/file_sys/archive_extsavedata.cpp | 9 | ||||
| -rw-r--r-- | src/core/hle/service/fs/archive.cpp | 23 | ||||
| -rw-r--r-- | src/core/hle/service/fs/archive.h | 4 | ||||
| -rw-r--r-- | src/core/hle/service/fs/fs_user.cpp | 16 |
4 files changed, 38 insertions, 14 deletions
diff --git a/src/core/file_sys/archive_extsavedata.cpp b/src/core/file_sys/archive_extsavedata.cpp index 975aafb35..e50c58a52 100644 --- a/src/core/file_sys/archive_extsavedata.cpp +++ b/src/core/file_sys/archive_extsavedata.cpp | |||
| @@ -71,7 +71,7 @@ bool ArchiveFactory_ExtSaveData::Initialize() { | |||
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_ExtSaveData::Open(const Path& path) { | 73 | ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_ExtSaveData::Open(const Path& path) { |
| 74 | std::string fullpath = GetExtSaveDataPath(mount_point, path); | 74 | std::string fullpath = GetExtSaveDataPath(mount_point, path) + "user/"; |
| 75 | if (!FileUtil::Exists(fullpath)) { | 75 | if (!FileUtil::Exists(fullpath)) { |
| 76 | // TODO(Subv): Check error code, this one is probably wrong | 76 | // TODO(Subv): Check error code, this one is probably wrong |
| 77 | return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS, | 77 | return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS, |
| @@ -82,8 +82,11 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_ExtSaveData::Open(cons | |||
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | ResultCode ArchiveFactory_ExtSaveData::Format(const Path& path) { | 84 | ResultCode ArchiveFactory_ExtSaveData::Format(const Path& path) { |
| 85 | std::string fullpath = GetExtSaveDataPath(mount_point, path); | 85 | // These folders are always created with the ExtSaveData |
| 86 | FileUtil::CreateFullPath(fullpath); | 86 | std::string user_path = GetExtSaveDataPath(mount_point, path) + "user/"; |
| 87 | std::string boss_path = GetExtSaveDataPath(mount_point, path) + "boss/"; | ||
| 88 | FileUtil::CreateFullPath(user_path); | ||
| 89 | FileUtil::CreateFullPath(boss_path); | ||
| 87 | return RESULT_SUCCESS; | 90 | return RESULT_SUCCESS; |
| 88 | } | 91 | } |
| 89 | 92 | ||
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index 7cab68024..4e275cb13 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp | |||
| @@ -406,7 +406,7 @@ ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::Path& path) { | |||
| 406 | return archive_itr->second->Format(path); | 406 | return archive_itr->second->Format(path); |
| 407 | } | 407 | } |
| 408 | 408 | ||
| 409 | ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low) { | 409 | ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low, VAddr icon_buffer, u32 icon_size) { |
| 410 | // Construct the binary path to the archive first | 410 | // Construct the binary path to the archive first |
| 411 | FileSys::Path path = FileSys::ConstructExtDataBinaryPath(static_cast<u32>(media_type), high, low); | 411 | FileSys::Path path = FileSys::ConstructExtDataBinaryPath(static_cast<u32>(media_type), high, low); |
| 412 | 412 | ||
| @@ -421,9 +421,25 @@ ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low) { | |||
| 421 | } | 421 | } |
| 422 | 422 | ||
| 423 | std::string base_path = FileSys::GetExtDataContainerPath(media_type_directory, media_type == MediaType::NAND); | 423 | std::string base_path = FileSys::GetExtDataContainerPath(media_type_directory, media_type == MediaType::NAND); |
| 424 | std::string extsavedata_path = FileSys::GetExtSaveDataPath(base_path, path); | 424 | std::string game_path = FileSys::GetExtSaveDataPath(base_path, path); |
| 425 | if (!FileUtil::CreateFullPath(extsavedata_path)) | 425 | // These two folders are always created with the ExtSaveData |
| 426 | std::string user_path = game_path + "user/"; | ||
| 427 | std::string boss_path = game_path + "boss/"; | ||
| 428 | if (!FileUtil::CreateFullPath(user_path)) | ||
| 429 | return ResultCode(-1); // TODO(Subv): Find the right error code | ||
| 430 | if (!FileUtil::CreateFullPath(boss_path)) | ||
| 431 | return ResultCode(-1); // TODO(Subv): Find the right error code | ||
| 432 | |||
| 433 | u8* smdh_icon = Memory::GetPointer(icon_buffer); | ||
| 434 | if (!smdh_icon) | ||
| 426 | return ResultCode(-1); // TODO(Subv): Find the right error code | 435 | return ResultCode(-1); // TODO(Subv): Find the right error code |
| 436 | |||
| 437 | // Create the icon | ||
| 438 | FileUtil::IOFile icon_file(game_path + "icon", "wb+"); | ||
| 439 | if (!icon_file.IsGood()) | ||
| 440 | return ResultCode(-1); // TODO(Subv): Find the right error code | ||
| 441 | |||
| 442 | icon_file.WriteBytes(smdh_icon, icon_size); | ||
| 427 | return RESULT_SUCCESS; | 443 | return RESULT_SUCCESS; |
| 428 | } | 444 | } |
| 429 | 445 | ||
| @@ -441,6 +457,7 @@ ResultCode DeleteExtSaveData(MediaType media_type, u32 high, u32 low) { | |||
| 441 | return ResultCode(-1); // TODO(Subv): Find the right error code | 457 | return ResultCode(-1); // TODO(Subv): Find the right error code |
| 442 | } | 458 | } |
| 443 | 459 | ||
| 460 | // Delete all directories (/user, /boss) and the icon file. | ||
| 444 | std::string base_path = FileSys::GetExtDataContainerPath(media_type_directory, media_type == MediaType::NAND); | 461 | std::string base_path = FileSys::GetExtDataContainerPath(media_type_directory, media_type == MediaType::NAND); |
| 445 | std::string extsavedata_path = FileSys::GetExtSaveDataPath(base_path, path); | 462 | std::string extsavedata_path = FileSys::GetExtSaveDataPath(base_path, path); |
| 446 | if (!FileUtil::DeleteDirRecursively(extsavedata_path)) | 463 | if (!FileUtil::DeleteDirRecursively(extsavedata_path)) |
diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h index faab0cb79..357b6b096 100644 --- a/src/core/hle/service/fs/archive.h +++ b/src/core/hle/service/fs/archive.h | |||
| @@ -177,9 +177,11 @@ ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::Path& path = File | |||
| 177 | * @param media_type The media type of the archive to create (NAND / SDMC) | 177 | * @param media_type The media type of the archive to create (NAND / SDMC) |
| 178 | * @param high The high word of the extdata id to create | 178 | * @param high The high word of the extdata id to create |
| 179 | * @param low The low word of the extdata id to create | 179 | * @param low The low word of the extdata id to create |
| 180 | * @param icon_buffer VAddr of the SMDH icon for this ExtSaveData | ||
| 181 | * @param icon_size Size of the SMDH icon | ||
| 180 | * @return ResultCode 0 on success or the corresponding code on error | 182 | * @return ResultCode 0 on success or the corresponding code on error |
| 181 | */ | 183 | */ |
| 182 | ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low); | 184 | ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low, VAddr icon_buffer, u32 icon_size); |
| 183 | 185 | ||
| 184 | /** | 186 | /** |
| 185 | * Deletes the SharedExtSaveData archive for the specified extdata ID | 187 | * Deletes the SharedExtSaveData archive for the specified extdata ID |
diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index 32db773bb..0ad44e55e 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp | |||
| @@ -504,9 +504,9 @@ static void FormatThisUserSaveData(Service::Interface* self) { | |||
| 504 | * 6 : Unknown | 504 | * 6 : Unknown |
| 505 | * 7 : Unknown | 505 | * 7 : Unknown |
| 506 | * 8 : Unknown | 506 | * 8 : Unknown |
| 507 | * 9 : Unknown | 507 | * 9 : Size of the SMDH icon |
| 508 | * 10: Unknown | 508 | * 10: (SMDH Size << 4) | 0x0000000A |
| 509 | * 11: Unknown | 509 | * 11: Pointer to the SMDH icon for the new ExtSaveData |
| 510 | * Outputs: | 510 | * Outputs: |
| 511 | * 1 : Result of function, 0 on success, otherwise error code | 511 | * 1 : Result of function, 0 on success, otherwise error code |
| 512 | */ | 512 | */ |
| @@ -516,14 +516,16 @@ static void CreateExtSaveData(Service::Interface* self) { | |||
| 516 | MediaType media_type = static_cast<MediaType>(cmd_buff[1] & 0xFF); | 516 | MediaType media_type = static_cast<MediaType>(cmd_buff[1] & 0xFF); |
| 517 | u32 save_low = cmd_buff[2]; | 517 | u32 save_low = cmd_buff[2]; |
| 518 | u32 save_high = cmd_buff[3]; | 518 | u32 save_high = cmd_buff[3]; |
| 519 | u32 icon_size = cmd_buff[9]; | ||
| 520 | VAddr icon_buffer = cmd_buff[11]; | ||
| 519 | 521 | ||
| 520 | LOG_WARNING(Service_FS, "(STUBBED) savedata_high=%08X savedata_low=%08X cmd_buff[3]=%08X " | 522 | LOG_WARNING(Service_FS, "(STUBBED) savedata_high=%08X savedata_low=%08X cmd_buff[3]=%08X " |
| 521 | "cmd_buff[4]=%08X cmd_buff[5]=%08X cmd_buff[6]=%08X cmd_buff[7]=%08X cmd_buff[8]=%08X " | 523 | "cmd_buff[4]=%08X cmd_buff[5]=%08X cmd_buff[6]=%08X cmd_buff[7]=%08X cmd_buff[8]=%08X " |
| 522 | "cmd_buff[9]=%08X cmd_buff[10]=%08X cmd_buff[11]=%08X", save_high, save_low, | 524 | "icon_size=%08X icon_descriptor=%08X icon_buffer=%08X", save_high, save_low, |
| 523 | cmd_buff[3], cmd_buff[4], cmd_buff[5], cmd_buff[6], cmd_buff[7], cmd_buff[8], cmd_buff[9], | 525 | cmd_buff[3], cmd_buff[4], cmd_buff[5], cmd_buff[6], cmd_buff[7], cmd_buff[8], icon_size, |
| 524 | cmd_buff[10], cmd_buff[11]); | 526 | cmd_buff[10], icon_buffer); |
| 525 | 527 | ||
| 526 | cmd_buff[1] = CreateExtSaveData(media_type, save_high, save_low).raw; | 528 | cmd_buff[1] = CreateExtSaveData(media_type, save_high, save_low, icon_buffer, icon_size).raw; |
| 527 | } | 529 | } |
| 528 | 530 | ||
| 529 | /** | 531 | /** |