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-9797 | ||||||||||||
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 9797 times by 48 tests: QFileInfo(path).isFile();return QFileInfo(path).isFile(); Executed by:
executed 9797 times by 48 tests: return QFileInfo(path).isFile(); Executed by:
| 9797 | ||||||||||||
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()
| 1080-2163 | ||||||||||||
19 | const QString path = *dir + QLatin1Char('/') + fileName; | - | ||||||||||||
20 | if (existsAsSpecified(path, options)
| 3-2160 | ||||||||||||
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 2160 times by 25 tests: end of block Executed by:
| 2160 | ||||||||||||
23 | return executed 1080 times by 25 tests: QString();return QString(); Executed by:
executed 1080 times by 25 tests: return QString(); Executed by:
| 1080 | ||||||||||||
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()
| 2631-7753 | ||||||||||||
30 | const QString path = *dir + QLatin1Char('/') + fileName; | - | ||||||||||||
31 | if (existsAsSpecified(path, options)
| 2690-5063 | ||||||||||||
32 | result.append(path); executed 2690 times by 24 tests: result.append(path); Executed by:
| 2690 | ||||||||||||
33 | } executed 7753 times by 25 tests: end of block Executed by:
| 7753 | ||||||||||||
34 | return executed 2631 times by 25 tests: result;return result; Executed by:
executed 2631 times by 25 tests: return result; Executed by:
| 2631 | ||||||||||||
35 | } | - | ||||||||||||
36 | static QString checkExecutable(const QString &path) | - | ||||||||||||
37 | { | - | ||||||||||||
38 | const QFileInfo info(path); | - | ||||||||||||
39 | if (info.isBundle()
| 0-239 | ||||||||||||
40 | return never executed: info.bundleName();return info.bundleName(); never executed: return info.bundleName(); | 0 | ||||||||||||
41 | if (info.isFile()
| 0-226 | ||||||||||||
42 | return executed 13 times by 3 tests: QDir::cleanPath(path);return QDir::cleanPath(path); Executed by:
executed 13 times by 3 tests: return QDir::cleanPath(path); Executed by:
| 13 | ||||||||||||
43 | return executed 226 times by 4 tests: QString();return QString(); Executed by:
executed 226 times by 4 tests: return QString(); Executed by:
| 226 | ||||||||||||
44 | } | - | ||||||||||||
45 | - | |||||||||||||
46 | static inline QString searchExecutable(const QStringList &searchPaths, | - | ||||||||||||
47 | const QString &executableName) | - | ||||||||||||
48 | { | - | ||||||||||||
49 | const QDir currentDir = QDir::current(); | - | ||||||||||||
50 | for (const QString &searchPath : searchPaths) { | - | ||||||||||||
51 | const QString candidate = currentDir.absoluteFilePath(searchPath + QLatin1Char('/') + executableName); | - | ||||||||||||
52 | const QString absPath = checkExecutable(candidate); | - | ||||||||||||
53 | if (!absPath.isEmpty()
| 12-225 | ||||||||||||
54 | return executed 12 times by 3 tests: absPath;return absPath; Executed by:
executed 12 times by 3 tests: return absPath; Executed by:
| 12 | ||||||||||||
55 | } executed 225 times by 4 tests: end of block Executed by:
| 225 | ||||||||||||
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-15 | ||||||||||||
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-15 | ||||||||||||
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 (const QString &rawPath : rawPaths) { | - | ||||||||||||
70 | QString cleanPath = QDir::cleanPath(rawPath); | - | ||||||||||||
71 | if (cleanPath.size() > 1
| 0-255 | ||||||||||||
72 | cleanPath.truncate(cleanPath.size() - 1); never executed: cleanPath.truncate(cleanPath.size() - 1); | 0 | ||||||||||||
73 | searchPaths.push_back(cleanPath); | - | ||||||||||||
74 | } executed 255 times by 4 tests: end of block Executed by:
| 255 | ||||||||||||
75 | } executed 15 times by 4 tests: end of block Executed by:
| 15 | ||||||||||||
76 | return executed 15 times by 4 tests: searchExecutable(searchPaths, executableName);return searchExecutable(searchPaths, executableName); Executed by:
executed 15 times by 4 tests: return searchExecutable(searchPaths, executableName); Executed by:
| 15 | ||||||||||||
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 block Executed by:
| 7 | ||||||||||||
135 | bool QStandardPaths::isTestModeEnabled() | - | ||||||||||||
136 | { | - | ||||||||||||
137 | return executed 3874 times by 53 tests: qsp_testMode;return qsp_testMode; Executed by:
executed 3874 times by 53 tests: return qsp_testMode; Executed by:
| 3874 | ||||||||||||
138 | } | - | ||||||||||||
139 | - | |||||||||||||
140 | - | |||||||||||||
141 | - | |||||||||||||
Switch to Source code | Preprocessed file |