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

Method detectSteamPath

ui-linux/src/backend.cpp:93–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91}
92
93void Backend::detectSteamPath()
94{
95 QString home = realHomePath();
96
97 QString path = home + "/.local/share/Steam";
98 if (QDir(path).exists()) {
99 m_steamPath = path;
100 } else {
101 path = home + "/.var/app/com.valvesoftware.Steam/.local/share/Steam";
102 if (QDir(path).exists())
103 m_steamPath = path;
104 else
105 m_steamPath = home + "/.steam/steam";
106 }
107
108 m_storagePath = crConfigDir() + "/storage";
109
110 m_deployed = false;
111 QString crPath = crDataDir() + "/cloud_redirect.so";
112 m_deployed = QFile::exists(crPath);
113
114 // Parse account ID from loginusers.vdf
115 QString loginUsersPath = m_steamPath + "/config/loginusers.vdf";
116 QFile f(loginUsersPath);
117 if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
118 QString content = f.readAll();
119 f.close();
120
121 QStringList lines = content.split('\n');
122 QString currentId;
123 QString currentPersonaName;
124 bool inUser = false;
125 int depth = 0;
126
127 for (const auto &line : lines) {
128 QString trimmed = line.trimmed();
129 if (trimmed == "{") { depth++; continue; }
130 if (trimmed == "}") { depth--; if (depth == 1) inUser = false; continue; }
131
132 if (depth == 1 && trimmed.startsWith('"')) {
133 int end = trimmed.indexOf('"', 1);
134 if (end > 1) {
135 QString key = trimmed.mid(1, end - 1);
136 bool ok;
137 quint64 sid = key.toULongLong(&ok);
138 if (ok && sid > 76561197960265728ULL) {
139 currentId = key;
140 currentPersonaName.clear();
141 inUser = true;
142 }
143 }
144 }
145
146 if (inUser && depth == 2) {
147 if (trimmed.contains("\"PersonaName\"")) {
148 int keyEndQuote = trimmed.indexOf('"', trimmed.indexOf('"') + 1);
149 int valStart = trimmed.indexOf('"', keyEndQuote + 1);
150 if (valStart > 0) {

Callers

nothing calls this directly

Calls 3

realHomePathFunction · 0.85
crConfigDirFunction · 0.85
crDataDirFunction · 0.85

Tested by

no test coverage detected