mirror of
https://github.com/RetroDECK/io.github.shiiion.primehack.git
synced 2024-12-04 19:15:39 +00:00
Improve flatpak detection patch
This commit is contained in:
parent
602582230f
commit
4fb50296b5
|
@ -1,56 +1,40 @@
|
|||
commit d4c899cede0743d40934ca11f83691cda72ff9dd
|
||||
Author: Carles Pastor <cpbadosa@gmail.com>
|
||||
Date: Sat Apr 2 20:47:06 2022 +0200
|
||||
|
||||
Detect when running inside a flatpak sandbox
|
||||
|
||||
diff --git a/Source/Core/UICommon/UICommon.cpp b/Source/Core/UICommon/UICommon.cpp
|
||||
index cb857fd3c7..47a012c4f0 100644
|
||||
index cb857fd3c7..e3ddde24fb 100644
|
||||
--- a/Source/Core/UICommon/UICommon.cpp
|
||||
+++ b/Source/Core/UICommon/UICommon.cpp
|
||||
@@ -306,19 +306,45 @@ void SetUserDirectory(std::string custom_path)
|
||||
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
|
||||
+ // We are on a non-Apple and non-Android POSIX system, there are 5 cases:
|
||||
+ // 1. Running inside flatpak sandbox
|
||||
+ // -> Use XDG basedir
|
||||
+ // 2. GetExeDirectory()/portable.txt exists
|
||||
@@ -309,24 +309,25 @@ void SetUserDirectory(std::string custom_path)
|
||||
// We are on a non-Apple and non-Android POSIX system, there are 4 cases:
|
||||
// 1. GetExeDirectory()/portable.txt exists
|
||||
// -> Use GetExeDirectory()/User
|
||||
- // 2. $DOLPHIN_EMU_USERPATH is set
|
||||
+ // 3. $DOLPHIN_EMU_USERPATH is set
|
||||
+ // 2. $DOLPHIN_EMU_USERPATH is set, and we're not in flatpak
|
||||
// -> Use $DOLPHIN_EMU_USERPATH
|
||||
- // 3. ~/.dolphin-emu directory exists
|
||||
+ // 4. ~/.dolphin-emu directory exists
|
||||
+ // 3. ~/.dolphin-emu directory exists, and we're not in flatpak
|
||||
// -> Use ~/.dolphin-emu
|
||||
- // 4. Default
|
||||
+ // 5. Default
|
||||
// 4. Default
|
||||
// -> Use XDG basedir, see
|
||||
// http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||
user_path = home_path + "." DOLPHIN_DATA_DIR DIR_SEP;
|
||||
std::string exe_path = File::GetExeDirectory();
|
||||
- if (File::Exists(exe_path + DIR_SEP "portable.txt"))
|
||||
+ if (File::Exists(DIR_SEP ".flatpak-info"))
|
||||
+ {
|
||||
+ const char* data_home = getenv("XDG_DATA_HOME");
|
||||
+ std::string data_path =
|
||||
+ std::string(data_home && data_home[0] == '/' ? data_home :
|
||||
+ (home_path + ".local" DIR_SEP "share")) +
|
||||
+ DIR_SEP DOLPHIN_DATA_DIR DIR_SEP;
|
||||
+
|
||||
+ const char* config_home = getenv("XDG_CONFIG_HOME");
|
||||
+ std::string config_path =
|
||||
+ std::string(config_home && config_home[0] == '/' ? config_home :
|
||||
+ (home_path + ".config")) +
|
||||
+ DIR_SEP DOLPHIN_DATA_DIR DIR_SEP;
|
||||
+
|
||||
+ const char* cache_home = getenv("XDG_CACHE_HOME");
|
||||
+ std::string cache_path =
|
||||
+ std::string(cache_home && cache_home[0] == '/' ? cache_home : (home_path + ".cache")) +
|
||||
+ DIR_SEP DOLPHIN_DATA_DIR DIR_SEP;
|
||||
+
|
||||
+ File::SetUserPath(D_USER_IDX, data_path);
|
||||
+ File::SetUserPath(D_CONFIG_IDX, config_path);
|
||||
+ File::SetUserPath(D_CACHE_IDX, cache_path);
|
||||
+ return;
|
||||
+ }
|
||||
+ else if (File::Exists(exe_path + DIR_SEP "portable.txt"))
|
||||
+ bool flatpak = File::Exists("/.flatpak-info");
|
||||
if (File::Exists(exe_path + DIR_SEP "portable.txt"))
|
||||
{
|
||||
user_path = exe_path + DIR_SEP "User" DIR_SEP;
|
||||
}
|
||||
- else if (env_path)
|
||||
+ else if (env_path && !flatpak)
|
||||
{
|
||||
user_path = env_path;
|
||||
}
|
||||
- else if (!File::Exists(user_path))
|
||||
+ else if (flatpak || !File::Exists(user_path))
|
||||
{
|
||||
const char* data_home = getenv("XDG_DATA_HOME");
|
||||
std::string data_path =
|
||||
|
|
Loading…
Reference in a new issue