QString ConfigFile::excludeFileFromSystem() { QFileInfo fi; #ifdef Q_OS_WIN fi.setFile(QCoreApplication::applicationDirPath(), exclFile); #endif #ifdef Q_OS_UNIX fi.setFile(QString(SYSCONFDIR "/" + Theme::instance()->appName()), exclFile); if (!fi.exists()) { // Prefer to return the preferred path! Only use the fallback location // if the other path does not exist and the fallback is valid. QFileInfo nextToBinary(QCoreApplication::applicationDirPath(), exclFile); if (nextToBinary.exists()) { fi = nextToBinary; } } #endif #ifdef Q_OS_MAC // exec path is inside the bundle fi.setFile(QCoreApplication::applicationDirPath(), QLatin1String("../Resources/") + exclFile); #endif return fi.absoluteFilePath(); }
QString ConfigFile::excludeFileFromSystem() { QFileInfo fi; #ifdef Q_OS_WIN fi.setFile(QCoreApplication::applicationDirPath(), exclFile); #endif #ifdef Q_OS_UNIX fi.setFile(QString(SYSCONFDIR "/" + Theme::instance()->appName()), exclFile); if (!fi.exists()) { // Prefer to return the preferred path! Only use the fallback location // if the other path does not exist and the fallback is valid. QFileInfo nextToBinary(QCoreApplication::applicationDirPath(), exclFile); if (nextToBinary.exists()) { fi = nextToBinary; } else { // For AppImage, the file might reside under a temporary mount path QDir d(QCoreApplication::applicationDirPath()); // supposed to be /tmp/mount.xyz/usr/bin d.cdUp(); // go out of bin d.cdUp(); // go out of usr if (!d.isRoot()) { // it is really a mountpoint if (d.cd("etc") && d.cd(Theme::instance()->appName())) { QFileInfo inMountDir(d, exclFile); if (inMountDir.exists()) { fi = inMountDir; } }; } } } #endif #ifdef Q_OS_MAC // exec path is inside the bundle fi.setFile(QCoreApplication::applicationDirPath(), QLatin1String("../Resources/") + exclFile); #endif return fi.absoluteFilePath(); }