aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/hle/service/fs/archive.cpp
diff options
context:
space:
mode:
authorGravatar Subv <subv2112@gmail.com>2014-12-29 13:04:37 -0500
committerGravatar Subv <subv2112@gmail.com>2014-12-29 22:29:55 -0500
commit2c89d4d5cd4e308b04cebb1c9bca48e12f0945da (patch)
treeea0a85e43943ba76418f27a68572e8602dbd9839 /src/core/hle/service/fs/archive.cpp
parent3d14eb285382740b144e5b047cb2ad072f6129ea (diff)
Archives: Implemented ExtSaveData and SharedExtSaveData
They will be stored in /extsavedata/SDMC and /extsavedata/NAND respectively. Also redirect some APT_A functions to their APT_U equivalents. Implemented the gamecoin.dat file in SharedExtSaveData in the PTM module. Implemented formatting the savegame. Retake a previous savegame if it exists instead of reporting them as not formatted every time a game is loaded.
Diffstat (limited to 'src/core/hle/service/fs/archive.cpp')
-rw-r--r--src/core/hle/service/fs/archive.cpp59
1 files changed, 32 insertions, 27 deletions
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp
index 487bf3aa..f19ca3a9 100644
--- a/src/core/hle/service/fs/archive.cpp
+++ b/src/core/hle/service/fs/archive.cpp
@@ -11,6 +11,7 @@
#include "common/math_util.h"
#include "core/file_sys/archive_savedata.h"
+#include "core/file_sys/archive_extsavedata.h"
#include "core/file_sys/archive_backend.h"
#include "core/file_sys/archive_sdmc.h"
#include "core/file_sys/directory_backend.h"
@@ -224,25 +225,20 @@ static Archive* GetArchive(ArchiveHandle handle) {
return (itr == handle_map.end()) ? nullptr : itr->second;
}
-ResultVal<ArchiveHandle> OpenArchive(ArchiveIdCode id_code) {
+ResultVal<ArchiveHandle> OpenArchive(ArchiveIdCode id_code, FileSys::Path& archive_path) {
LOG_TRACE(Service_FS, "Opening archive with id code 0x%08X", id_code);
auto itr = id_code_map.find(id_code);
if (itr == id_code_map.end()) {
- if (id_code == ArchiveIdCode::SaveData) {
- // When a SaveData archive is created for the first time, it is not yet formatted
- // and the save file/directory structure expected by the game has not yet been initialized.
- // Returning the NotFormatted error code will signal the game to provision the SaveData archive
- // with the files and folders that it expects.
- // The FormatSaveData service call will create the SaveData archive when it is called.
- return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS,
- ErrorSummary::InvalidState, ErrorLevel::Status);
- }
// TODO: Verify error against hardware
return ResultCode(ErrorDescription::NotFound, ErrorModule::FS,
ErrorSummary::NotFound, ErrorLevel::Permanent);
}
+ ResultCode res = itr->second->backend->Open(archive_path);
+ if (!res.IsSuccess())
+ return res;
+
// This should never even happen in the first place with 64-bit handles,
while (handle_map.count(next_handle) != 0) {
++next_handle;
@@ -395,25 +391,14 @@ ResultVal<Handle> OpenDirectoryFromArchive(ArchiveHandle archive_handle, const F
}
ResultCode FormatSaveData() {
- // TODO(Subv): Actually wipe the savedata folder after creating or opening it
-
// Do not create the archive again if it already exists
- if (id_code_map.find(ArchiveIdCode::SaveData) != id_code_map.end())
- return UnimplementedFunction(ErrorModule::FS); // TODO(Subv): Find the correct error code
-
- // Create the SaveData archive
- std::string savedata_directory = FileUtil::GetUserPath(D_SAVEDATA_IDX);
- auto savedata_archive = Common::make_unique<FileSys::Archive_SaveData>(savedata_directory,
- Kernel::g_program_id);
-
- if (savedata_archive->Initialize()) {
- CreateArchive(std::move(savedata_archive), ArchiveIdCode::SaveData);
- return RESULT_SUCCESS;
- } else {
- LOG_ERROR(Service_FS, "Can't instantiate SaveData archive with path %s",
- savedata_archive->GetMountPoint().c_str());
- return UnimplementedFunction(ErrorModule::FS); // TODO(Subv): Find the proper error code
+ auto archive_itr = id_code_map.find(ArchiveIdCode::SaveData);
+ if (archive_itr == id_code_map.end()) {
+ return UnimplementedFunction(ErrorModule::FS); // TODO(Subv): Find the right error
}
+
+ // Use an empty path, we do not use it when formatting the savedata
+ return archive_itr->second->backend->Format(FileSys::Path());
}
/// Initialize archives
@@ -430,6 +415,26 @@ void ArchiveInit() {
CreateArchive(std::move(sdmc_archive), ArchiveIdCode::SDMC);
else
LOG_ERROR(Service_FS, "Can't instantiate SDMC archive with path %s", sdmc_directory.c_str());
+
+ // Create the SaveData archive
+ std::string savedata_directory = FileUtil::GetUserPath(D_SAVEDATA_IDX);
+ auto savedata_archive = Common::make_unique<FileSys::Archive_SaveData>(savedata_directory);
+ CreateArchive(std::move(savedata_archive), ArchiveIdCode::SaveData);
+
+ std::string extsavedata_directory = FileUtil::GetUserPath(D_EXTSAVEDATA);
+ auto extsavedata_archive = Common::make_unique<FileSys::Archive_ExtSaveData>(extsavedata_directory);
+ if (extsavedata_archive->Initialize())
+ CreateArchive(std::move(extsavedata_archive), ArchiveIdCode::ExtSaveData);
+ else
+ LOG_ERROR(Service_FS, "Can't instantiate ExtSaveData archive with path %s", extsavedata_directory.c_str());
+
+ std::string sharedextsavedata_directory = FileUtil::GetUserPath(D_EXTSAVEDATA);
+ auto sharedextsavedata_archive = Common::make_unique<FileSys::Archive_ExtSaveData>(sharedextsavedata_directory);
+ if (sharedextsavedata_archive->Initialize())
+ CreateArchive(std::move(sharedextsavedata_archive), ArchiveIdCode::SharedExtSaveData);
+ else
+ LOG_ERROR(Service_FS, "Can't instantiate SharedExtSaveData archive with path %s",
+ sharedextsavedata_directory.c_str());
}
/// Shutdown archives