VERY experimental Nintendo Switch 2 emulator
C++
[user] prioritize 'user' directory if it exists (without needing a portable build) + docs (#338)
lizzie2f82b63e6ad4
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 03f97eb7e5..5e3a45d8c5 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -117,8 +117,6 @@ option(YUZU_ENABLE_LTO "Enable link-time optimization" OFF)option(YUZU_DOWNLOAD_TIME_ZONE_DATA "Always download time zone binaries" ON)-option(YUZU_ENABLE_PORTABLE "Allow yuzu to enable portable mode if a user folder is found in the CWD" ON)-CMAKE_DEPENDENT_OPTION(YUZU_USE_FASTER_LD "Check if a faster linker is available" ON "NOT WIN32" OFF)CMAKE_DEPENDENT_OPTION(USE_SYSTEM_MOLTENVK "Use the system MoltenVK lib (instead of the bundled one)" OFF "APPLE" OFF)diff --git a/docs/User.md b/docs/User.mdnew file mode 100644index 0000000000..cfc81063f8--- /dev/null+++ b/docs/User.md@@ -0,0 +1,11 @@+# User configuration++## Configuration directories++Eden will store configuration in the following directories:++- **Windows**: `%AppData%\Roaming`.+- **Android**: Data is stored internally.+- **Linux, macOS, FreeBSD, Solaris, OpenBSD**: `$XDG_DATA_HOME`, `$XDG_CACHE_HOME`, `$XDG_CONFIG_HOME`.++If a `user` directory is present in the current working directory, that will override all global configuration directories and the emulator will use that instead.diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txtindex 1aa433db32..9b898837bc 100644--- a/src/common/CMakeLists.txt+++ b/src/common/CMakeLists.txt@@ -162,10 +162,6 @@ add_library(zstd_compression.h)-if(YUZU_ENABLE_PORTABLE)- add_compile_definitions(YUZU_ENABLE_PORTABLE)-endif()-if(WIN32)target_sources(common PRIVATE windows/timer_resolution.cppwindows/timer_resolution.h)diff --git a/src/common/fs/fs_paths.h b/src/common/fs/fs_paths.hindex 40891380c9..5cdf9be39d 100644--- a/src/common/fs/fs_paths.h+++ b/src/common/fs/fs_paths.h@@ -12,7 +12,6 @@#define PORTABLE_DIR "user"// Sub-directories contained within a yuzu data directory-#define AMIIBO_DIR "amiibo"#define CACHE_DIR "cache"#define CONFIG_DIR "config"@@ -28,11 +27,12 @@#define SHADER_DIR "shader"#define TAS_DIR "tas"#define ICONS_DIR "icons"++// Compatibility with other emulators#define CITRON_DIR "citron"#define SUDACHI_DIR "sudachi"#define YUZU_DIR "yuzu"#define SUYU_DIR "suyu"// yuzu-specific files-#define LOG_FILE "eden_log.txt"diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cppindex fa1403225e..a2f5cb92ff 100644--- a/src/common/fs/path_util.cpp+++ b/src/common/fs/path_util.cpp@@ -101,61 +101,53 @@ public:legacy_paths.insert_or_assign(legacy_path, new_path);}+ /// In non-android devices, the current directory will first search for "user"+ /// if such directory (and it must be a directory) is found, that takes priority+ /// over the global configuration directory (in other words, portable directories+ /// take priority over the global ones, always)+ /// On Android, the behaviour is to look for the current directory only.void Reinitialize(fs::path eden_path = {}) {fs::path eden_path_cache;fs::path eden_path_config;-#ifdef _WIN32-#ifdef YUZU_ENABLE_PORTABLE+ // User directory takes priority over global %AppData% directoryeden_path = GetExeDirectory() / PORTABLE_DIR;-#endif- if (!IsDir(eden_path)) {+ if (!Exists(eden_path) || !IsDir(eden_path)) {eden_path = GetAppDataRoamingDirectory() / EDEN_DIR;}-eden_path_cache = eden_path / CACHE_DIR;eden_path_config = eden_path / CONFIG_DIR;-#define LEGACY_PATH(titleName, upperName) GenerateLegacyPath(LegacyPath::titleName##Dir, GetAppDataRoamingDirectory() / upperName##_DIR); \GenerateLegacyPath(LegacyPath::titleName##ConfigDir, GetAppDataRoamingDirectory() / upperName##_DIR / CONFIG_DIR); \GenerateLegacyPath(LegacyPath::titleName##CacheDir, GetAppDataRoamingDirectory() / upperName##_DIR / CACHE_DIR);-LEGACY_PATH(Citron, CITRON)LEGACY_PATH(Sudachi, SUDACHI)LEGACY_PATH(Yuzu, YUZU)LEGACY_PATH(Suyu, SUYU)#undef LEGACY_PATH-#elif ANDROIDASSERT(!eden_path.empty());eden_path_cache = eden_path / CACHE_DIR;eden_path_config = eden_path / CONFIG_DIR;#else-#ifdef YUZU_ENABLE_PORTABLEeden_path = GetCurrentDir() / PORTABLE_DIR;-#endif- if (Exists(eden_path) && IsDir(eden_path)) {- eden_path_cache = eden_path / CACHE_DIR;- eden_path_config = eden_path / CONFIG_DIR;- } else {+ if (!Exists(eden_path) || !IsDir(eden_path)) {eden_path = GetDataDirectory("XDG_DATA_HOME") / EDEN_DIR;eden_path_cache = GetDataDirectory("XDG_CACHE_HOME") / EDEN_DIR;eden_path_config = GetDataDirectory("XDG_CONFIG_HOME") / EDEN_DIR;+ } else {+ eden_path_cache = eden_path / CACHE_DIR;+ eden_path_config = eden_path / CONFIG_DIR;}-#define LEGACY_PATH(titleName, upperName) GenerateLegacyPath(LegacyPath::titleName##Dir, GetDataDirectory("XDG_DATA_HOME") / upperName##_DIR); \GenerateLegacyPath(LegacyPath::titleName##ConfigDir, GetDataDirectory("XDG_CONFIG_HOME") / upperName##_DIR); \GenerateLegacyPath(LegacyPath::titleName##CacheDir, GetDataDirectory("XDG_CACHE_HOME") / upperName##_DIR);-LEGACY_PATH(Citron, CITRON)LEGACY_PATH(Sudachi, SUDACHI)LEGACY_PATH(Yuzu, YUZU)LEGACY_PATH(Suyu, SUYU)-#undef LEGACY_PATH-#endif-GenerateEdenPath(EdenPath::EdenDir, eden_path);GenerateEdenPath(EdenPath::AmiiboDir, eden_path / AMIIBO_DIR);GenerateEdenPath(EdenPath::CacheDir, eden_path_cache);