MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / getCustomPaths

Function getCustomPaths

src/App/Application.cpp:3471–3507  ·  view source on GitHub ↗

! * \brief getCustomPaths * Returns a tuple of path names where to store config, data and temp. files. * The method therefore reads the environment variables: * \list * \li FREECAD_USER_HOME * \li FREECAD_USER_DATA * \li FREECAD_USER_TEMP * \endlist */

Source from the content-addressed store, hash-verified

3469 * \endlist
3470 */
3471std::tuple<QString, QString, QString> getCustomPaths()
3472{
3473 const QProcessEnvironment env(QProcessEnvironment::systemEnvironment());
3474 QString userHome = env.value(QStringLiteral("FREECAD_USER_HOME"));
3475 QString userData = env.value(QStringLiteral("FREECAD_USER_DATA"));
3476 QString userTemp = env.value(QStringLiteral("FREECAD_USER_TEMP"));
3477
3478 auto toNativePath = [](QString& path) {
3479 if (!path.isEmpty()) {
3480 const QDir dir(path);
3481 if (dir.exists())
3482 path = QDir::toNativeSeparators(dir.canonicalPath());
3483 else
3484 path.clear();
3485 }
3486 };
3487
3488 // verify env. variables
3489 toNativePath(userHome);
3490 toNativePath(userData);
3491 toNativePath(userTemp);
3492
3493 // if FREECAD_USER_HOME is set but not FREECAD_USER_DATA
3494 if (!userHome.isEmpty() && userData.isEmpty()) {
3495 userData = userHome;
3496 }
3497
3498 // if FREECAD_USER_HOME is set but not FREECAD_USER_TEMP
3499 if (!userHome.isEmpty() && userTemp.isEmpty()) {
3500 const QDir dir(userHome);
3501 dir.mkdir(QStringLiteral("temp"));
3502 const QFileInfo fi(dir, QStringLiteral("temp"));
3503 userTemp = fi.absoluteFilePath();
3504 }
3505
3506 return {userHome, userData, userTemp};
3507}
3508
3509/*!
3510 * \brief getStandardPaths

Callers 2

configurePathsMethod · 0.85
ExtractUserPathMethod · 0.85

Calls 5

valueMethod · 0.45
isEmptyMethod · 0.45
existsMethod · 0.45
canonicalPathMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected