Merge pull request #10430 from OatmealDome/mac-portable

UICommon: Add support for portable.txt on macOS
This commit is contained in:
JMC47 2022-07-08 18:41:14 -04:00 committed by GitHub
commit 7853b72c46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 40 additions and 31 deletions

View File

@ -299,17 +299,7 @@ void SetUserDirectory(std::string custom_path)
home = ""; home = "";
std::string home_path = std::string(home) + DIR_SEP; std::string home_path = std::string(home) + DIR_SEP;
#if defined(__APPLE__) || defined(ANDROID) // On a non-Apple and non-Android POSIX system, there are 4 cases:
if (env_path)
{
user_path = env_path;
}
else
{
user_path = home_path + DOLPHIN_DATA_DIR DIR_SEP;
}
#else
// We are on a non-Apple and non-Android POSIX system, there are 4 cases:
// 1. GetExeDirectory()/portable.txt exists // 1. GetExeDirectory()/portable.txt exists
// -> Use GetExeDirectory()/User // -> Use GetExeDirectory()/User
// 2. $DOLPHIN_EMU_USERPATH is set // 2. $DOLPHIN_EMU_USERPATH is set
@ -319,7 +309,15 @@ void SetUserDirectory(std::string custom_path)
// 4. Default // 4. Default
// -> Use XDG basedir, see // -> Use XDG basedir, see
// http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html // http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
user_path = home_path + "." DOLPHIN_DATA_DIR DIR_SEP; //
// On macOS:
// 1. GetExeDirectory()/portable.txt exists
// -> Use GetExeDirectory()/User
// 2. $DOLPHIN_EMU_USERPATH is set
// -> Use $DOLPHIN_EMU_USERPATH
// 3. Default
//
// On Android, custom_path is set, so this code path is never reached.
std::string exe_path = File::GetExeDirectory(); std::string exe_path = File::GetExeDirectory();
if (File::Exists(exe_path + DIR_SEP "portable.txt")) if (File::Exists(exe_path + DIR_SEP "portable.txt"))
{ {
@ -329,7 +327,17 @@ void SetUserDirectory(std::string custom_path)
{ {
user_path = env_path; user_path = env_path;
} }
else if (!File::Exists(user_path)) #if defined(__APPLE__) || defined(ANDROID)
else
{
user_path = home_path + DOLPHIN_DATA_DIR DIR_SEP;
}
#else
else
{
user_path = home_path + "." DOLPHIN_DATA_DIR DIR_SEP;
if (!File::Exists(user_path))
{ {
const char* data_home = getenv("XDG_DATA_HOME"); const char* data_home = getenv("XDG_DATA_HOME");
std::string data_path = std::string data_path =
@ -353,6 +361,7 @@ void SetUserDirectory(std::string custom_path)
File::SetUserPath(D_CACHE_IDX, cache_path); File::SetUserPath(D_CACHE_IDX, cache_path);
return; return;
} }
}
#endif #endif
} }
#endif #endif