| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/io/qstandardpaths.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | - | |||||||||||||
| 7 | - | |||||||||||||
| 8 | - | |||||||||||||
| 9 | static bool existsAsSpecified(const QString &path, QStandardPaths::LocateOptions options) | - | ||||||||||||
| 10 | { | - | ||||||||||||
| 11 | if (options & QStandardPaths::LocateDirectory
| 119-1907 | ||||||||||||
| 12 | return executed 119 times by 2 tests: QDir(path).exists();return QDir(path).exists();Executed by:
executed 119 times by 2 tests: return QDir(path).exists();Executed by:
| 119 | ||||||||||||
| 13 | return executed 1907 times by 27 tests: QFileInfo(path).isFile();return QFileInfo(path).isFile();Executed by:
executed 1907 times by 27 tests: return QFileInfo(path).isFile();Executed by:
| 1907 | ||||||||||||
| 14 | } | - | ||||||||||||
| 15 | QString QStandardPaths::locate(StandardLocation type, const QString &fileName, LocateOptions options) | - | ||||||||||||
| 16 | { | - | ||||||||||||
| 17 | const QStringList &dirs = standardLocations(type); | - | ||||||||||||
| 18 | for (QStringList::const_iterator dir = dirs.constBegin(); dir != dirs.constEnd()
| 870-1743 | ||||||||||||
| 19 | const QString path = *dir + QLatin1Char('/') + fileName; | - | ||||||||||||
| 20 | if (existsAsSpecified(path, options)
| 3-1740 | ||||||||||||
| 21 | return executed 3 times by 2 tests: path;return path;Executed by:
executed 3 times by 2 tests: return path;Executed by:
| 3 | ||||||||||||
| 22 | } executed 1740 times by 24 tests: end of blockExecuted by:
| 1740 | ||||||||||||
| 23 | return executed 870 times by 24 tests: QString();return QString();Executed by:
executed 870 times by 24 tests: return QString();Executed by:
| 870 | ||||||||||||
| 24 | } | - | ||||||||||||
| 25 | QStringList QStandardPaths::locateAll(StandardLocation type, const QString &fileName, LocateOptions options) | - | ||||||||||||
| 26 | { | - | ||||||||||||
| 27 | const QStringList &dirs = standardLocations(type); | - | ||||||||||||
| 28 | QStringList result; | - | ||||||||||||
| 29 | for (QStringList::const_iterator dir = dirs.constBegin(); dir != dirs.constEnd()
| 141-283 | ||||||||||||
| 30 | const QString path = *dir + QLatin1Char('/') + fileName; | - | ||||||||||||
| 31 | if (existsAsSpecified(path, options)
| 83-200 | ||||||||||||
| 32 | result.append(path); executed 200 times by 3 tests: result.append(path);Executed by:
| 200 | ||||||||||||
| 33 | } executed 283 times by 4 tests: end of blockExecuted by:
| 283 | ||||||||||||
| 34 | return executed 141 times by 4 tests: result;return result;Executed by:
executed 141 times by 4 tests: return result;Executed by:
| 141 | ||||||||||||
| 35 | } | - | ||||||||||||
| 36 | static QString checkExecutable(const QString &path) | - | ||||||||||||
| 37 | { | - | ||||||||||||
| 38 | const QFileInfo info(path); | - | ||||||||||||
| 39 | if (info.isBundle()
| 0-168 | ||||||||||||
| 40 | return never executed: info.bundleName();return info.bundleName();never executed: return info.bundleName(); | 0 | ||||||||||||
| 41 | if (info.isFile()
| 0-156 | ||||||||||||
| 42 | return executed 12 times by 2 tests: QDir::cleanPath(path);return QDir::cleanPath(path);Executed by:
executed 12 times by 2 tests: return QDir::cleanPath(path);Executed by:
| 12 | ||||||||||||
| 43 | return executed 156 times by 3 tests: QString();return QString();Executed by:
executed 156 times by 3 tests: return QString();Executed by:
| 156 | ||||||||||||
| 44 | } | - | ||||||||||||
| 45 | - | |||||||||||||
| 46 | static inline QString searchExecutable(const QStringList &searchPaths, | - | ||||||||||||
| 47 | const QString &executableName) | - | ||||||||||||
| 48 | { | - | ||||||||||||
| 49 | const QDir currentDir = QDir::current(); | - | ||||||||||||
| 50 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(searchPaths)>::type> _container_((searchPaths)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QString &searchPath = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 51 | const QString candidate = currentDir.absoluteFilePath(searchPath + QLatin1Char('/') + executableName); | - | ||||||||||||
| 52 | const QString absPath = checkExecutable(candidate); | - | ||||||||||||
| 53 | if (!absPath.isEmpty()
| 11-155 | ||||||||||||
| 54 | return executed 11 times by 2 tests: absPath;return absPath;Executed by:
executed 11 times by 2 tests: return absPath;Executed by:
| 11 | ||||||||||||
| 55 | } executed 155 times by 3 tests: end of blockExecuted by:
| 155 | ||||||||||||
| 56 | return executed 3 times by 2 tests: QString();return QString();Executed by:
executed 3 times by 2 tests: return QString();Executed by:
| 3 | ||||||||||||
| 57 | } | - | ||||||||||||
| 58 | QString QStandardPaths::findExecutable(const QString &executableName, const QStringList &paths) | - | ||||||||||||
| 59 | { | - | ||||||||||||
| 60 | if (QFileInfo(executableName).isAbsolute()
| 2-14 | ||||||||||||
| 61 | return executed 2 times by 1 test: checkExecutable(executableName);return checkExecutable(executableName);Executed by:
executed 2 times by 1 test: return checkExecutable(executableName);Executed by:
| 2 | ||||||||||||
| 62 | - | |||||||||||||
| 63 | QStringList searchPaths = paths; | - | ||||||||||||
| 64 | if (paths.isEmpty()
| 0-14 | ||||||||||||
| 65 | QByteArray pEnv = qgetenv("PATH"); | - | ||||||||||||
| 66 | - | |||||||||||||
| 67 | const QStringList rawPaths = QString::fromLocal8Bit(pEnv.constData()).split(QDir::listSeparator(), QString::SkipEmptyParts); | - | ||||||||||||
| 68 | searchPaths.reserve(rawPaths.size()); | - | ||||||||||||
| 69 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(rawPaths)>::type> _container_((rawPaths)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QString &rawPath = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 70 | QString cleanPath = QDir::cleanPath(rawPath); | - | ||||||||||||
| 71 | if (cleanPath.size() > 1
| 0-182 | ||||||||||||
| 72 | cleanPath.truncate(cleanPath.size() - 1); never executed: cleanPath.truncate(cleanPath.size() - 1); | 0 | ||||||||||||
| 73 | searchPaths.push_back(cleanPath); | - | ||||||||||||
| 74 | } executed 182 times by 3 tests: end of blockExecuted by:
| 182 | ||||||||||||
| 75 | } executed 14 times by 3 tests: end of blockExecuted by:
| 14 | ||||||||||||
| 76 | return executed 14 times by 3 tests: searchExecutable(searchPaths, executableName);return searchExecutable(searchPaths, executableName);Executed by:
executed 14 times by 3 tests: return searchExecutable(searchPaths, executableName);Executed by:
| 14 | ||||||||||||
| 77 | } | - | ||||||||||||
| 78 | QString QStandardPaths::displayName(StandardLocation type) | - | ||||||||||||
| 79 | { | - | ||||||||||||
| 80 | switch (type) { | - | ||||||||||||
| 81 | case executed 1 time by 1 test: DesktopLocation:case DesktopLocation:Executed by:
executed 1 time by 1 test: case DesktopLocation:Executed by:
| 1 | ||||||||||||
| 82 | return executed 1 time by 1 test: QCoreApplication::translate("QStandardPaths", "Desktop");return QCoreApplication::translate("QStandardPaths", "Desktop");Executed by:
executed 1 time by 1 test: return QCoreApplication::translate("QStandardPaths", "Desktop");Executed by:
| 1 | ||||||||||||
| 83 | case executed 1 time by 1 test: DocumentsLocation:case DocumentsLocation:Executed by:
executed 1 time by 1 test: case DocumentsLocation:Executed by:
| 1 | ||||||||||||
| 84 | return executed 1 time by 1 test: QCoreApplication::translate("QStandardPaths", "Documents");return QCoreApplication::translate("QStandardPaths", "Documents");Executed by:
executed 1 time by 1 test: return QCoreApplication::translate("QStandardPaths", "Documents");Executed by:
| 1 | ||||||||||||
| 85 | case executed 1 time by 1 test: FontsLocation:case FontsLocation:Executed by:
executed 1 time by 1 test: case FontsLocation:Executed by:
| 1 | ||||||||||||
| 86 | return executed 1 time by 1 test: QCoreApplication::translate("QStandardPaths", "Fonts");return QCoreApplication::translate("QStandardPaths", "Fonts");Executed by:
executed 1 time by 1 test: return QCoreApplication::translate("QStandardPaths", "Fonts");Executed by:
| 1 | ||||||||||||
| 87 | case executed 1 time by 1 test: ApplicationsLocation:case ApplicationsLocation:Executed by:
executed 1 time by 1 test: case ApplicationsLocation:Executed by:
| 1 | ||||||||||||
| 88 | return executed 1 time by 1 test: QCoreApplication::translate("QStandardPaths", "Applications");return QCoreApplication::translate("QStandardPaths", "Applications");Executed by:
executed 1 time by 1 test: return QCoreApplication::translate("QStandardPaths", "Applications");Executed by:
| 1 | ||||||||||||
| 89 | case executed 1 time by 1 test: MusicLocation:case MusicLocation:Executed by:
executed 1 time by 1 test: case MusicLocation:Executed by:
| 1 | ||||||||||||
| 90 | return executed 1 time by 1 test: QCoreApplication::translate("QStandardPaths", "Music");return QCoreApplication::translate("QStandardPaths", "Music");Executed by:
executed 1 time by 1 test: return QCoreApplication::translate("QStandardPaths", "Music");Executed by:
| 1 | ||||||||||||
| 91 | case executed 1 time by 1 test: MoviesLocation:case MoviesLocation:Executed by:
executed 1 time by 1 test: case MoviesLocation:Executed by:
| 1 | ||||||||||||
| 92 | return executed 1 time by 1 test: QCoreApplication::translate("QStandardPaths", "Movies");return QCoreApplication::translate("QStandardPaths", "Movies");Executed by:
executed 1 time by 1 test: return QCoreApplication::translate("QStandardPaths", "Movies");Executed by:
| 1 | ||||||||||||
| 93 | case executed 1 time by 1 test: PicturesLocation:case PicturesLocation:Executed by:
executed 1 time by 1 test: case PicturesLocation:Executed by:
| 1 | ||||||||||||
| 94 | return executed 1 time by 1 test: QCoreApplication::translate("QStandardPaths", "Pictures");return QCoreApplication::translate("QStandardPaths", "Pictures");Executed by:
executed 1 time by 1 test: return QCoreApplication::translate("QStandardPaths", "Pictures");Executed by:
| 1 | ||||||||||||
| 95 | case executed 1 time by 1 test: TempLocation:case TempLocation:Executed by:
executed 1 time by 1 test: case TempLocation:Executed by:
| 1 | ||||||||||||
| 96 | return executed 1 time by 1 test: QCoreApplication::translate("QStandardPaths", "Temporary Directory");return QCoreApplication::translate("QStandardPaths", "Temporary Directory");Executed by:
executed 1 time by 1 test: return QCoreApplication::translate("QStandardPaths", "Temporary Directory");Executed by:
| 1 | ||||||||||||
| 97 | case executed 1 time by 1 test: HomeLocation:case HomeLocation:Executed by:
executed 1 time by 1 test: case HomeLocation:Executed by:
| 1 | ||||||||||||
| 98 | return executed 1 time by 1 test: QCoreApplication::translate("QStandardPaths", "Home");return QCoreApplication::translate("QStandardPaths", "Home");Executed by:
executed 1 time by 1 test: return QCoreApplication::translate("QStandardPaths", "Home");Executed by:
| 1 | ||||||||||||
| 99 | case never executed: CacheLocation:case CacheLocation:never executed: case CacheLocation: | 0 | ||||||||||||
| 100 | return never executed: QCoreApplication::translate("QStandardPaths", "Cache");return QCoreApplication::translate("QStandardPaths", "Cache");never executed: return QCoreApplication::translate("QStandardPaths", "Cache"); | 0 | ||||||||||||
| 101 | case never executed: GenericDataLocation:case GenericDataLocation:never executed: case GenericDataLocation: | 0 | ||||||||||||
| 102 | return never executed: QCoreApplication::translate("QStandardPaths", "Shared Data");return QCoreApplication::translate("QStandardPaths", "Shared Data");never executed: return QCoreApplication::translate("QStandardPaths", "Shared Data"); | 0 | ||||||||||||
| 103 | case never executed: RuntimeLocation:case RuntimeLocation:never executed: case RuntimeLocation: | 0 | ||||||||||||
| 104 | return never executed: QCoreApplication::translate("QStandardPaths", "Runtime");return QCoreApplication::translate("QStandardPaths", "Runtime");never executed: return QCoreApplication::translate("QStandardPaths", "Runtime"); | 0 | ||||||||||||
| 105 | case never executed: ConfigLocation:case ConfigLocation:never executed: case ConfigLocation: | 0 | ||||||||||||
| 106 | return never executed: QCoreApplication::translate("QStandardPaths", "Configuration");return QCoreApplication::translate("QStandardPaths", "Configuration");never executed: return QCoreApplication::translate("QStandardPaths", "Configuration"); | 0 | ||||||||||||
| 107 | case never executed: GenericConfigLocation:case GenericConfigLocation:never executed: case GenericConfigLocation: | 0 | ||||||||||||
| 108 | return never executed: QCoreApplication::translate("QStandardPaths", "Shared Configuration");return QCoreApplication::translate("QStandardPaths", "Shared Configuration");never executed: return QCoreApplication::translate("QStandardPaths", "Shared Configuration"); | 0 | ||||||||||||
| 109 | case never executed: GenericCacheLocation:case GenericCacheLocation:never executed: case GenericCacheLocation: | 0 | ||||||||||||
| 110 | return never executed: QCoreApplication::translate("QStandardPaths", "Shared Cache");return QCoreApplication::translate("QStandardPaths", "Shared Cache");never executed: return QCoreApplication::translate("QStandardPaths", "Shared Cache"); | 0 | ||||||||||||
| 111 | case executed 1 time by 1 test: DownloadLocation:case DownloadLocation:Executed by:
executed 1 time by 1 test: case DownloadLocation:Executed by:
| 1 | ||||||||||||
| 112 | return executed 1 time by 1 test: QCoreApplication::translate("QStandardPaths", "Download");return QCoreApplication::translate("QStandardPaths", "Download");Executed by:
executed 1 time by 1 test: return QCoreApplication::translate("QStandardPaths", "Download");Executed by:
| 1 | ||||||||||||
| 113 | case never executed: AppDataLocation:case AppDataLocation:never executed: case AppDataLocation: | 0 | ||||||||||||
| 114 | case executed 1 time by 1 test: AppLocalDataLocation:case AppLocalDataLocation:Executed by:
executed 1 time by 1 test: case AppLocalDataLocation:Executed by:
| 1 | ||||||||||||
| 115 | return executed 1 time by 1 test: QCoreApplication::translate("QStandardPaths", "Application Data");return QCoreApplication::translate("QStandardPaths", "Application Data");Executed by:
executed 1 time by 1 test: return QCoreApplication::translate("QStandardPaths", "Application Data");Executed by:
| 1 | ||||||||||||
| 116 | case never executed: AppConfigLocation:case AppConfigLocation:never executed: case AppConfigLocation: | 0 | ||||||||||||
| 117 | return never executed: QCoreApplication::translate("QStandardPaths", "Application Configuration");return QCoreApplication::translate("QStandardPaths", "Application Configuration");never executed: return QCoreApplication::translate("QStandardPaths", "Application Configuration"); | 0 | ||||||||||||
| 118 | } | - | ||||||||||||
| 119 | - | |||||||||||||
| 120 | return never executed: QString();return QString();never executed: return QString(); | 0 | ||||||||||||
| 121 | } | - | ||||||||||||
| 122 | static bool qsp_testMode = false; | - | ||||||||||||
| 123 | - | |||||||||||||
| 124 | - | |||||||||||||
| 125 | void QStandardPaths::enableTestMode(bool testMode) | - | ||||||||||||
| 126 | { | - | ||||||||||||
| 127 | qsp_testMode = testMode; | - | ||||||||||||
| 128 | } never executed: end of block | 0 | ||||||||||||
| 129 | - | |||||||||||||
| 130 | - | |||||||||||||
| 131 | void QStandardPaths::setTestModeEnabled(bool testMode) | - | ||||||||||||
| 132 | { | - | ||||||||||||
| 133 | qsp_testMode = testMode; | - | ||||||||||||
| 134 | } executed 7 times by 5 tests: end of blockExecuted by:
| 7 | ||||||||||||
| 135 | bool QStandardPaths::isTestModeEnabled() | - | ||||||||||||
| 136 | { | - | ||||||||||||
| 137 | return executed 1153 times by 37 tests: qsp_testMode;return qsp_testMode;Executed by:
executed 1153 times by 37 tests: return qsp_testMode;Executed by:
| 1153 | ||||||||||||
| 138 | } | - | ||||||||||||
| 139 | - | |||||||||||||
| 140 | - | |||||||||||||
| 141 | - | |||||||||||||
| Switch to Source code | Preprocessed file |