Merge pull request #4249 from FearlessTobi/port-760

Port yuzu-emu/yuzu#760: "file_util: Use an enum class for GetUserPath()"
This commit is contained in:
Weiyi Wang 2018-09-22 23:42:59 -04:00 committed by GitHub
commit 20e42592ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 106 additions and 89 deletions

View file

@ -571,9 +571,9 @@ ResultCode DeleteExtSaveData(MediaType media_type, u32 high, u32 low) {
std::string media_type_directory;
if (media_type == MediaType::NAND) {
media_type_directory = FileUtil::GetUserPath(D_NAND_IDX);
media_type_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir);
} else if (media_type == MediaType::SDMC) {
media_type_directory = FileUtil::GetUserPath(D_SDMC_IDX);
media_type_directory = FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir);
} else {
LOG_ERROR(Service_FS, "Unsupported media type {}", static_cast<u32>(media_type));
return ResultCode(-1); // TODO(Subv): Find the right error code
@ -592,7 +592,7 @@ ResultCode DeleteSystemSaveData(u32 high, u32 low) {
// Construct the binary path to the archive first
FileSys::Path path = FileSys::ConstructSystemSaveDataBinaryPath(high, low);
std::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX);
std::string nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir);
std::string base_path = FileSys::GetSystemSaveDataContainerPath(nand_directory);
std::string systemsavedata_path = FileSys::GetSystemSaveDataPath(base_path, path);
if (!FileUtil::DeleteDirRecursively(systemsavedata_path))
@ -604,7 +604,7 @@ ResultCode CreateSystemSaveData(u32 high, u32 low) {
// Construct the binary path to the archive first
FileSys::Path path = FileSys::ConstructSystemSaveDataBinaryPath(high, low);
std::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX);
std::string nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir);
std::string base_path = FileSys::GetSystemSaveDataContainerPath(nand_directory);
std::string systemsavedata_path = FileSys::GetSystemSaveDataPath(base_path, path);
if (!FileUtil::CreateFullPath(systemsavedata_path))
@ -616,8 +616,8 @@ void RegisterArchiveTypes() {
// TODO(Subv): Add the other archive types (see here for the known types:
// http://3dbrew.org/wiki/FS:OpenArchive#Archive_idcodes).
std::string sdmc_directory = FileUtil::GetUserPath(D_SDMC_IDX);
std::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX);
std::string sdmc_directory = FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir);
std::string nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir);
auto sdmc_factory = std::make_unique<FileSys::ArchiveFactory_SDMC>(sdmc_directory);
if (sdmc_factory->Initialize())
RegisterArchiveType(std::move(sdmc_factory), ArchiveIdCode::SDMC);