MCPcopy Create free account
hub / github.com/PrismLauncher/PrismLauncher / nearestExistentAncestor

Function nearestExistentAncestor

launcher/FileSystem.cpp:1193–1206  ·  view source on GitHub ↗

* @brief path to the near ancestor that exists * */

Source from the content-addressed store, hash-verified

1191 *
1192 */
1193QString nearestExistentAncestor(const QString& path)
1194{
1195 if (QFileInfo::exists(path))
1196 return path;
1197
1198 QDir dir(path);
1199 if (!dir.makeAbsolute())
1200 return {};
1201 do {
1202 dir.setPath(QDir::cleanPath(dir.filePath(QStringLiteral(".."))));
1203 } while (!dir.exists() && !dir.isRoot());
1204
1205 return dir.exists() ? dir.path() : QString();
1206}
1207
1208/**
1209 * @brief colect information about the filesystem under a file

Callers 1

statFSFunction · 0.85

Calls 6

cleanPathFunction · 0.85
filePathMethod · 0.80
QStringClass · 0.70
setPathMethod · 0.45
existsMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected