mirror of
https://github.com/Dark98/threeSD.git
synced 2026-07-02 16:49:04 +00:00
Support SDMC/NAND path redirecting
Added inih as an external.
This commit is contained in:
@@ -7,3 +7,6 @@
|
||||
[submodule "qdevicewatcher"]
|
||||
path = externals/qdevicewatcher/qdevicewatcher
|
||||
url = https://github.com/wang-bin/qdevicewatcher.git
|
||||
[submodule "inih"]
|
||||
path = externals/inih/inih
|
||||
url = https://github.com/benhoyt/inih.git
|
||||
|
||||
Vendored
+3
@@ -4,5 +4,8 @@ add_subdirectory(cryptopp)
|
||||
# fmt
|
||||
add_subdirectory(fmt)
|
||||
|
||||
# inih
|
||||
add_subdirectory(inih)
|
||||
|
||||
# QDeviceWatcher
|
||||
add_subdirectory(qdevicewatcher)
|
||||
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
add_library(inih
|
||||
inih/ini.c
|
||||
inih/ini.h
|
||||
inih/cpp/INIReader.cpp
|
||||
inih/cpp/INIReader.h
|
||||
)
|
||||
target_include_directories(inih INTERFACE .)
|
||||
|
||||
target_compile_definitions(inih PRIVATE -DINI_MAX_LINE=1000)
|
||||
+1
Submodule externals/inih/inih added at 4f251f0ff7
@@ -18,4 +18,4 @@ add_library(common STATIC
|
||||
thread.h
|
||||
)
|
||||
|
||||
target_link_libraries(common PUBLIC fmt)
|
||||
target_link_libraries(common PUBLIC fmt inih)
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <inih/cpp/INIReader.h>
|
||||
#include "common/assert.h"
|
||||
#include "common/common_funcs.h"
|
||||
#include "common/common_paths.h"
|
||||
@@ -724,6 +725,32 @@ UserPathType GetUserPathType() {
|
||||
#endif
|
||||
}
|
||||
|
||||
static void UpdateUserPathFromConfig() {
|
||||
// Locate config file. Choose one that exists, or, if both don't exist, quit.
|
||||
std::string config_path = g_paths[UserPath::ConfigDir] + "qt-config.ini";
|
||||
std::string section_name = "Data%20Storage"; // For whatever reason they're different
|
||||
if (!Exists(config_path)) {
|
||||
config_path = g_paths[UserPath::ConfigDir] + "sdl2-config.ini";
|
||||
section_name = "Data Storage";
|
||||
if (!Exists(config_path)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
INIReader ini(config_path);
|
||||
const auto nand_dir = ini.GetString(section_name, "nand_directory", "");
|
||||
if (!nand_dir.empty()) {
|
||||
LOG_INFO(Common_Filesystem, "Using NAND directory {}", nand_dir);
|
||||
g_paths[UserPath::NANDDir] = nand_dir + DIR_SEP;
|
||||
}
|
||||
|
||||
const auto sdmc_dir = ini.GetString(section_name, "sdmc_directory", "");
|
||||
if (!sdmc_dir.empty()) {
|
||||
LOG_INFO(Common_Filesystem, "Using SDMC directory {}", sdmc_dir);
|
||||
g_paths[UserPath::SDMCDir] = sdmc_dir + DIR_SEP;
|
||||
}
|
||||
}
|
||||
|
||||
void SetUserPath(const std::string& path) {
|
||||
if (!g_paths.empty()) {
|
||||
g_paths.clear();
|
||||
@@ -780,6 +807,8 @@ void SetUserPath(const std::string& path) {
|
||||
}
|
||||
g_paths.emplace(UserPath::SDMCDir, user_path + SDMC_DIR DIR_SEP);
|
||||
g_paths.emplace(UserPath::NANDDir, user_path + NAND_DIR DIR_SEP);
|
||||
UpdateUserPathFromConfig();
|
||||
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user