aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/file_sys/archive_savedata.cpp
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner <yuriks@yuriks.net>2015-02-06 11:53:14 -0200
committerGravatar Yuri Kunde Schlesner <yuriks@yuriks.net>2015-02-10 13:43:44 -0200
commit3f1a3952d707bce7851652ce54701ca14334f314 (patch)
tree04c79ff9887f0074813276cdf989e6814901e943 /src/core/file_sys/archive_savedata.cpp
parent4468625080c9388f2fe81a791e8295e6961e96f5 (diff)
FS: Allow multiple instances of the same archive type to be open at once
Diffstat (limited to 'src/core/file_sys/archive_savedata.cpp')
-rw-r--r--src/core/file_sys/archive_savedata.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/core/file_sys/archive_savedata.cpp b/src/core/file_sys/archive_savedata.cpp
index 3baee529..8496e06f 100644
--- a/src/core/file_sys/archive_savedata.cpp
+++ b/src/core/file_sys/archive_savedata.cpp
@@ -6,6 +6,7 @@
#include "common/common_types.h"
#include "common/file_util.h"
+#include "common/make_unique.h"
#include "core/file_sys/archive_savedata.h"
#include "core/file_sys/disk_archive.h"
@@ -28,26 +29,28 @@ static std::string GetSaveDataPath(const std::string& mount_location, u64 progra
return Common::StringFromFormat("%s%08x/%08x/data/00000001/", mount_location.c_str(), high, low);
}
-Archive_SaveData::Archive_SaveData(const std::string& sdmc_directory)
- : DiskArchive(GetSaveDataContainerPath(sdmc_directory)) {
+ArchiveFactory_SaveData::ArchiveFactory_SaveData(const std::string& sdmc_directory)
+ : mount_point(GetSaveDataContainerPath(sdmc_directory)) {
LOG_INFO(Service_FS, "Directory %s set as SaveData.", this->mount_point.c_str());
}
-ResultCode Archive_SaveData::Open(const Path& path) {
- if (concrete_mount_point.empty())
- concrete_mount_point = GetSaveDataPath(mount_point, Kernel::g_program_id);
+ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SaveData::Open(const Path& path) {
+ std::string concrete_mount_point = GetSaveDataPath(mount_point, Kernel::g_program_id);
if (!FileUtil::Exists(concrete_mount_point)) {
// 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.
+ // 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.
return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS,
ErrorSummary::InvalidState, ErrorLevel::Status);
}
- return RESULT_SUCCESS;
+
+ auto archive = Common::make_unique<DiskArchive>(std::move(concrete_mount_point));
+ return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
}
-ResultCode Archive_SaveData::Format(const Path& path) const {
+ResultCode ArchiveFactory_SaveData::Format(const Path& path) {
+ std::string concrete_mount_point = GetSaveDataPath(mount_point, Kernel::g_program_id);
FileUtil::DeleteDirRecursively(concrete_mount_point);
FileUtil::CreateFullPath(concrete_mount_point);
return RESULT_SUCCESS;