mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-13 16:28:33 -05:00
FS: Allow multiple instances of the same archive type to be open at once
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user