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:
parent
49c0766b73
commit
3be52f818a
4 changed files with 19 additions and 3 deletions
|
@ -306,7 +306,7 @@ void Config::ReadDataStorageValues() {
|
|||
Settings::values.nand_dir = ReadSetting(QStringLiteral("nand_directory"), QString::fromStdString(nan_dir))
|
||||
.toString()
|
||||
.toStdString();
|
||||
std::string sdmc_dir = FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir);
|
||||
std::string sdmc_dir = FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir);
|
||||
Settings::values.sdmc_dir = ReadSetting(QStringLiteral("sdmc_directory"), QString::fromStdString(sdmc_dir))
|
||||
.toString()
|
||||
.toStdString();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue