citra-emu
/
citra-canary
Archived
1
0
Fork 0

file_util: Add a function to update the user path

Added a default value when sdmc and nand are empty
This commit is contained in:
Daniel Méndez 2021-04-10 20:48:28 +02:00
parent 49c0766b73
commit 3be52f818a
4 changed files with 19 additions and 3 deletions

View File

@ -12,6 +12,7 @@
#include "common/common_paths.h"
#include "common/file_util.h"
#include "common/logging/log.h"
#include "core/settings.h"
#ifdef _WIN32
#include <windows.h>
@ -716,8 +717,13 @@ void SetUserPath(const std::string& path) {
}
#endif
}
g_paths.emplace(UserPath::SDMCDir, user_path + SDMC_DIR DIR_SEP);
g_paths.emplace(UserPath::NANDDir, user_path + NAND_DIR DIR_SEP);
g_paths.emplace(UserPath::SDMCDir, !Settings::values.sdmc_dir.empty()
? Settings::values.sdmc_dir
: user_path + SDMC_DIR DIR_SEP);
g_paths.emplace(UserPath::NANDDir, !Settings::values.nand_dir.empty()
? Settings::values.nand_dir
: user_path + NAND_DIR DIR_SEP);
g_paths.emplace(UserPath::SysDataDir, user_path + SYSDATA_DIR DIR_SEP);
// TODO: Put the logs in a better location for each OS
g_paths.emplace(UserPath::LogDir, user_path + LOG_DIR DIR_SEP);
@ -762,6 +768,11 @@ const std::string& GetUserPath(UserPath path) {
SetUserPath();
return g_paths[path];
}
const void UpdateUserPath(UserPath path, const std::string& filename) {
g_paths[path] = filename + DIR_SEP;
}
std::size_t WriteStringToFile(bool text_file, const std::string& filename, std::string_view str) {
return IOFile(filename, text_file ? "w" : "wb").WriteString(str);
}

View File

@ -186,6 +186,9 @@ void SetCurrentRomPath(const std::string& path);
// directory. To be used in "multi-user" mode (that is, installed).
[[nodiscard]] const std::string& GetUserPath(UserPath path);
// Update the Global Path with the new value
const void UpdateUserPath(UserPath path, const std::string& filename);
// Returns the path to where the sys file are
[[nodiscard]] std::string GetSysDirectory();

View File

@ -118,6 +118,8 @@ void LogSettings() {
log_setting("Camera_OuterLeftConfig", values.camera_config[OuterLeftCamera]);
log_setting("Camera_OuterLeftFlip", values.camera_flip[OuterLeftCamera]);
log_setting("DataStorage_UseVirtualSd", values.use_virtual_sd);
log_setting("DataStorage_SdmcDir", values.sdmc_dir);
log_setting("DataStorage_NandDir", values.nand_dir);
log_setting("System_IsNew3ds", values.is_new_3ds);
log_setting("System_RegionValue", values.region_value);
log_setting("Debugging_UseGdbstub", values.use_gdbstub);