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:
commit
20e42592ff
15 changed files with 106 additions and 89 deletions
|
@ -440,11 +440,13 @@ std::string GetTitlePath(Service::FS::MediaType media_type, u64 tid) {
|
|||
|
||||
std::string GetMediaTitlePath(Service::FS::MediaType media_type) {
|
||||
if (media_type == Service::FS::MediaType::NAND)
|
||||
return fmt::format("{}{}/title/", FileUtil::GetUserPath(D_NAND_IDX), SYSTEM_ID);
|
||||
return fmt::format("{}{}/title/", FileUtil::GetUserPath(FileUtil::UserPath::NANDDir),
|
||||
SYSTEM_ID);
|
||||
|
||||
if (media_type == Service::FS::MediaType::SDMC)
|
||||
return fmt::format("{}Nintendo 3DS/{}/{}/title/", FileUtil::GetUserPath(D_SDMC_IDX),
|
||||
SYSTEM_ID, SDCARD_ID);
|
||||
return fmt::format("{}Nintendo 3DS/{}/{}/title/",
|
||||
FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir), SYSTEM_ID,
|
||||
SDCARD_ID);
|
||||
|
||||
if (media_type == Service::FS::MediaType::GameCard) {
|
||||
// TODO(shinyquagsire23): get current app parent folder if TID matches?
|
||||
|
|
|
@ -171,7 +171,7 @@ bool Module::LoadLegacySharedFont() {
|
|||
// generated by the APT:U service. The best way to get is by dumping it from RAM. We've provided
|
||||
// a homebrew app to do this: https://github.com/citra-emu/3dsutils. Put the resulting file
|
||||
// "shared_font.bin" in the Citra "sysdata" directory.
|
||||
std::string filepath = FileUtil::GetUserPath(D_SYSDATA_IDX) + SHARED_FONT;
|
||||
std::string filepath = FileUtil::GetUserPath(FileUtil::UserPath::SysDataDir) + SHARED_FONT;
|
||||
|
||||
FileUtil::CreateFullPath(filepath); // Create path if not already created
|
||||
FileUtil::IOFile file(filepath, "rb");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -70,7 +70,7 @@ AESKey HexToKey(const std::string& hex) {
|
|||
}
|
||||
|
||||
void LoadPresetKeys() {
|
||||
const std::string filepath = FileUtil::GetUserPath(D_SYSDATA_IDX) + AES_KEYS;
|
||||
const std::string filepath = FileUtil::GetUserPath(FileUtil::UserPath::SysDataDir) + AES_KEYS;
|
||||
FileUtil::CreateFullPath(filepath); // Create path if not already created
|
||||
std::ifstream file;
|
||||
OpenFStream(file, filepath, std::ios_base::in);
|
||||
|
|
|
@ -45,7 +45,8 @@ static u64 GenerateTelemetryId() {
|
|||
|
||||
u64 GetTelemetryId() {
|
||||
u64 telemetry_id{};
|
||||
const std::string filename{FileUtil::GetUserPath(D_CONFIG_IDX) + "telemetry_id"};
|
||||
const std::string filename{FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) +
|
||||
"telemetry_id"};
|
||||
|
||||
if (FileUtil::Exists(filename)) {
|
||||
FileUtil::IOFile file(filename, "rb");
|
||||
|
@ -69,7 +70,8 @@ u64 GetTelemetryId() {
|
|||
|
||||
u64 RegenerateTelemetryId() {
|
||||
const u64 new_telemetry_id{GenerateTelemetryId()};
|
||||
const std::string filename{FileUtil::GetUserPath(D_CONFIG_IDX) + "telemetry_id"};
|
||||
const std::string filename{FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) +
|
||||
"telemetry_id"};
|
||||
|
||||
FileUtil::IOFile file(filename, "wb");
|
||||
if (!file.IsOpen()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue