FS: Allow multiple instances of the same archive type to be open at once

This commit is contained in:
Yuri Kunde Schlesner
2015-02-06 11:53:14 -02:00
parent 4468625080
commit 3f1a3952d7
19 changed files with 199 additions and 159 deletions

View File

@ -6,6 +6,7 @@
#include "common/common_types.h"
#include "common/file_util.h"
#include "common/make_unique.h"
#include "core/file_sys/archive_sdmc.h"
#include "core/file_sys/disk_archive.h"
@ -16,17 +17,17 @@
namespace FileSys {
Archive_SDMC::Archive_SDMC(const std::string& sdmc_directory) : DiskArchive(sdmc_directory) {
ArchiveFactory_SDMC::ArchiveFactory_SDMC(const std::string& sdmc_directory) : sdmc_directory(sdmc_directory) {
LOG_INFO(Service_FS, "Directory %s set as SDMC.", sdmc_directory.c_str());
}
bool Archive_SDMC::Initialize() {
bool ArchiveFactory_SDMC::Initialize() {
if (!Settings::values.use_virtual_sd) {
LOG_WARNING(Service_FS, "SDMC disabled by config.");
return false;
}
if (!FileUtil::CreateFullPath(mount_point)) {
if (!FileUtil::CreateFullPath(sdmc_directory)) {
LOG_ERROR(Service_FS, "Unable to create SDMC path.");
return false;
}
@ -34,4 +35,14 @@ bool Archive_SDMC::Initialize() {
return true;
}
ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SDMC::Open(const Path& path) {
auto archive = Common::make_unique<DiskArchive>(sdmc_directory);
return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
}
ResultCode ArchiveFactory_SDMC::Format(const Path& path) {
// This is kind of an undesirable operation, so let's just ignore it. :)
return RESULT_SUCCESS;
}
} // namespace FileSys