Merge pull request #4532 from Neui/env-var-usr-cfg
Use $DOLPHIN_EMU_PATH as an alternative for the user directory
This commit is contained in:
commit
793c6d25f4
|
@ -188,7 +188,8 @@ rules folder.
|
||||||
A number of user writeable directories are created for caching purposes or for
|
A number of user writeable directories are created for caching purposes or for
|
||||||
allowing the user to edit their contents. On macOS and Linux these folders are
|
allowing the user to edit their contents. On macOS and Linux these folders are
|
||||||
stored in `~/Library/Application Support/Dolphin/` and `~/.dolphin-emu`
|
stored in `~/Library/Application Support/Dolphin/` and `~/.dolphin-emu`
|
||||||
respectively. On Windows the user directory is stored in the `My Documents`
|
respectively, but can be overwritten by setting the environment variable
|
||||||
|
`DOLPHIN_EMU_USERPATH`. On Windows the user directory is stored in the `My Documents`
|
||||||
folder by default, but there are various way to override this behavior:
|
folder by default, but there are various way to override this behavior:
|
||||||
|
|
||||||
* Creating a file called `portable.txt` next to the Dolphin executable will
|
* Creating a file called `portable.txt` next to the Dolphin executable will
|
||||||
|
|
|
@ -160,6 +160,7 @@ void SetUserDirectory(const std::string& custom_path)
|
||||||
// Make sure it ends in DIR_SEP.
|
// Make sure it ends in DIR_SEP.
|
||||||
if (*user_path.rbegin() != DIR_SEP_CHR)
|
if (*user_path.rbegin() != DIR_SEP_CHR)
|
||||||
user_path += DIR_SEP;
|
user_path += DIR_SEP;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
if (File::Exists(ROOT_DIR DIR_SEP USERDATA_DIR))
|
if (File::Exists(ROOT_DIR DIR_SEP USERDATA_DIR))
|
||||||
{
|
{
|
||||||
|
@ -167,6 +168,7 @@ void SetUserDirectory(const std::string& custom_path)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
const char* env_path = getenv("DOLPHIN_EMU_USERPATH");
|
||||||
const char* home = getenv("HOME");
|
const char* home = getenv("HOME");
|
||||||
if (!home)
|
if (!home)
|
||||||
home = getenv("PWD");
|
home = getenv("PWD");
|
||||||
|
@ -175,14 +177,23 @@ void SetUserDirectory(const std::string& custom_path)
|
||||||
std::string home_path = std::string(home) + DIR_SEP;
|
std::string home_path = std::string(home) + DIR_SEP;
|
||||||
|
|
||||||
#if defined(__APPLE__) || defined(ANDROID)
|
#if defined(__APPLE__) || defined(ANDROID)
|
||||||
user_path = home_path + DOLPHIN_DATA_DIR DIR_SEP;
|
if (env_path)
|
||||||
|
{
|
||||||
|
user_path = env_path;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
user_path = home_path + DOLPHIN_DATA_DIR DIR_SEP;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
// We are on a non-Apple and non-Android POSIX system, there are 3 cases:
|
// 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 directory exists
|
// 2. $DOLPHIN_EMU_USERPATH is set
|
||||||
|
// -> Use $DOLPHIN_EMU_USERPATH
|
||||||
|
// 3. ~/.dolphin-emu directory exists
|
||||||
// -> Use ~/.dolphin-emu
|
// -> Use ~/.dolphin-emu
|
||||||
// 3. 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;
|
user_path = home_path + "." DOLPHIN_DATA_DIR DIR_SEP;
|
||||||
|
@ -191,6 +202,10 @@ void SetUserDirectory(const std::string& custom_path)
|
||||||
{
|
{
|
||||||
user_path = exe_path + DIR_SEP "User" DIR_SEP;
|
user_path = exe_path + DIR_SEP "User" DIR_SEP;
|
||||||
}
|
}
|
||||||
|
else if (env_path)
|
||||||
|
{
|
||||||
|
user_path = env_path;
|
||||||
|
}
|
||||||
else if (!File::Exists(user_path))
|
else if (!File::Exists(user_path))
|
||||||
{
|
{
|
||||||
const char* data_home = getenv("XDG_DATA_HOME");
|
const char* data_home = getenv("XDG_DATA_HOME");
|
||||||
|
|
Loading…
Reference in New Issue