aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/file_sys/archive_extsavedata.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_extsavedata.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_extsavedata.cpp')
-rw-r--r--src/core/file_sys/archive_extsavedata.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/core/file_sys/archive_extsavedata.cpp b/src/core/file_sys/archive_extsavedata.cpp
index 33e4e76f..0363c977 100644
--- a/src/core/file_sys/archive_extsavedata.cpp
+++ b/src/core/file_sys/archive_extsavedata.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_extsavedata.h"
#include "core/file_sys/disk_archive.h"
@@ -33,12 +34,12 @@ std::string GetExtDataContainerPath(const std::string& mount_point, bool shared)
SYSTEM_ID.c_str(), SDCARD_ID.c_str());
}
-Archive_ExtSaveData::Archive_ExtSaveData(const std::string& mount_location, bool shared)
- : DiskArchive(GetExtDataContainerPath(mount_location, shared)) {
+ArchiveFactory_ExtSaveData::ArchiveFactory_ExtSaveData(const std::string& mount_location, bool shared)
+ : mount_point(GetExtDataContainerPath(mount_location, shared)) {
LOG_INFO(Service_FS, "Directory %s set as base for ExtSaveData.", mount_point.c_str());
}
-bool Archive_ExtSaveData::Initialize() {
+bool ArchiveFactory_ExtSaveData::Initialize() {
if (!FileUtil::CreateFullPath(mount_point)) {
LOG_ERROR(Service_FS, "Unable to create ExtSaveData base path.");
return false;
@@ -47,18 +48,18 @@ bool Archive_ExtSaveData::Initialize() {
return true;
}
-ResultCode Archive_ExtSaveData::Open(const Path& path) {
+ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_ExtSaveData::Open(const Path& path) {
std::string fullpath = GetExtSaveDataPath(mount_point, path);
if (!FileUtil::Exists(fullpath)) {
// TODO(Subv): Check error code, this one is probably wrong
return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS,
ErrorSummary::InvalidState, ErrorLevel::Status);
}
- concrete_mount_point = fullpath;
- return RESULT_SUCCESS;
+ auto archive = Common::make_unique<DiskArchive>(fullpath);
+ return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
}
-ResultCode Archive_ExtSaveData::Format(const Path& path) const {
+ResultCode ArchiveFactory_ExtSaveData::Format(const Path& path) {
std::string fullpath = GetExtSaveDataPath(mount_point, path);
FileUtil::CreateFullPath(fullpath);
return RESULT_SUCCESS;