MCPcopy Create free account
hub / github.com/Selectively11/CloudRedirect / realHomePath

Function realHomePath

ui-linux/src/utils.h:10–37  ·  view source on GitHub ↗

Real home dir (Flatpak remaps QDir::homePath to the sandbox).

Source from the content-addressed store, hash-verified

8
9// Real home dir (Flatpak remaps QDir::homePath to the sandbox).
10inline QString realHomePath()
11{
12 if (QFile::exists("/.flatpak-info")) {
13 // Try HOST_HOME environment variable first
14 const char* hostHome = std::getenv("HOST_HOME");
15 if (hostHome && hostHome[0])
16 return QString::fromUtf8(hostHome);
17
18 // Parse real home from /etc/passwd
19 QFile passwd("/etc/passwd");
20 if (passwd.open(QIODevice::ReadOnly | QIODevice::Text)) {
21 uid_t uid = getuid();
22 while (!passwd.atEnd()) {
23 QString line = passwd.readLine();
24 QStringList fields = line.split(':');
25 if (fields.size() >= 6 && fields[2].toULongLong() == static_cast<qulonglong>(uid))
26 return fields[5];
27 }
28 }
29
30 // Last resort: strip the .var/app/<app-id> suffix
31 QString sandboxHome = QDir::homePath();
32 int varAppIdx = sandboxHome.indexOf("/.var/app/");
33 if (varAppIdx > 0)
34 return sandboxHome.left(varAppIdx);
35 }
36 return QDir::homePath();
37}
38
39inline bool inFlatpak()
40{

Callers 5

detectSteamPathMethod · 0.85
loadSLSsteamAppsMethod · 0.85
checkPrerequisitesMethod · 0.85
xdgConfigHomeFunction · 0.85
xdgDataHomeFunction · 0.85

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected