Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | static bool existsAsSpecified(const QString &path, QStandardPaths::LocateOptions options) | - |
10 | { | - |
11 | if (options & QStandardPaths::LocateDirectory) evaluated: options & QStandardPaths::LocateDirectory yes Evaluation Count:5 | yes Evaluation Count:121 |
| 5-121 |
12 | return QDir(path).exists(); executed: return QDir(path).exists(); Execution Count:5 | 5 |
13 | return QFileInfo(path).isFile(); executed: return QFileInfo(path).isFile(); Execution Count:121 | 121 |
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(); ++dir) { evaluated: dir != dirs.constEnd() yes Evaluation Count:4 | yes Evaluation Count:1 |
| 1-4 |
19 | const QString path = *dir + QLatin1Char('/') + fileName; | - |
20 | if (existsAsSpecified(path, options)) evaluated: existsAsSpecified(path, options) yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
21 | return path; executed: return path; Execution Count:2 | 2 |
22 | } executed: } Execution Count:2 | 2 |
23 | return QString(); executed: return QString(); Execution Count:1 | 1 |
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(); ++dir) { evaluated: dir != dirs.constEnd() yes Evaluation Count:122 | yes Evaluation Count:61 |
| 61-122 |
30 | const QString path = *dir + QLatin1Char('/') + fileName; | - |
31 | if (existsAsSpecified(path, options)) evaluated: existsAsSpecified(path, options) yes Evaluation Count:77 | yes Evaluation Count:45 |
| 45-77 |
32 | result.append(path); executed: result.append(path); Execution Count:77 | 77 |
33 | } executed: } Execution Count:122 | 122 |
34 | return result; executed: return result; Execution Count:61 | 61 |
35 | } | - |
36 | static QString checkExecutable(const QString &path) | - |
37 | { | - |
38 | const QFileInfo info(path); | - |
39 | if (info.isBundle()) partially evaluated: info.isBundle() no Evaluation Count:0 | yes Evaluation Count:122 |
| 0-122 |
40 | return info.bundleName(); never executed: return info.bundleName(); | 0 |
41 | if (info.isFile() && info.isExecutable()) evaluated: info.isFile() yes Evaluation Count:10 | yes Evaluation Count:112 |
partially evaluated: info.isExecutable() yes Evaluation Count:10 | no Evaluation Count:0 |
| 0-112 |
42 | return QDir::cleanPath(path); executed: return QDir::cleanPath(path); Execution Count:10 | 10 |
43 | return QString(); executed: return QString(); Execution Count:112 | 112 |
44 | } | - |
45 | | - |
46 | static inline QString searchExecutable(const QStringList &searchPaths, | - |
47 | const QString &executableName) | - |
48 | { | - |
49 | const QDir currentDir = QDir::current(); | - |
50 | for (QForeachContainer<__typeof__(searchPaths)> _container_(searchPaths); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QString &searchPath = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
51 | const QString candidate = currentDir.absoluteFilePath(searchPath + QLatin1Char('/') + executableName); | - |
52 | const QString absPath = checkExecutable(candidate); | - |
53 | if (!absPath.isEmpty()) evaluated: !absPath.isEmpty() yes Evaluation Count:9 | yes Evaluation Count:111 |
| 9-111 |
54 | return absPath; executed: return absPath; Execution Count:9 | 9 |
55 | } executed: } Execution Count:111 | 111 |
56 | return QString(); executed: return QString(); Execution Count:2 | 2 |
57 | } | - |
58 | QString QStandardPaths::findExecutable(const QString &executableName, const QStringList &paths) | - |
59 | { | - |
60 | if (QFileInfo(executableName).isAbsolute()) evaluated: QFileInfo(executableName).isAbsolute() yes Evaluation Count:2 | yes Evaluation Count:11 |
| 2-11 |
61 | return checkExecutable(executableName); executed: return checkExecutable(executableName); Execution Count:2 | 2 |
62 | | - |
63 | QStringList searchPaths = paths; | - |
64 | if (paths.isEmpty()) { partially evaluated: paths.isEmpty() yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
65 | QByteArray pEnv = qgetenv("PATH"); | - |
66 | | - |
67 | | - |
68 | | - |
69 | const QLatin1Char pathSep(':'); | - |
70 | | - |
71 | | - |
72 | const QStringList rawPaths = QString::fromLocal8Bit(pEnv.constData()).split(pathSep, QString::SkipEmptyParts); | - |
73 | searchPaths.reserve(rawPaths.size()); | - |
74 | for (QForeachContainer<__typeof__(rawPaths)> _container_(rawPaths); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QString &rawPath = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
75 | QString cleanPath = QDir::cleanPath(rawPath); | - |
76 | if (cleanPath.size() > 1 && cleanPath.endsWith(QLatin1Char('/'))) partially evaluated: cleanPath.size() > 1 yes Evaluation Count:143 | no Evaluation Count:0 |
partially evaluated: cleanPath.endsWith(QLatin1Char('/')) no Evaluation Count:0 | yes Evaluation Count:143 |
| 0-143 |
77 | cleanPath.truncate(cleanPath.size() - 1); never executed: cleanPath.truncate(cleanPath.size() - 1); | 0 |
78 | searchPaths.push_back(cleanPath); | - |
79 | } executed: } Execution Count:143 | 143 |
80 | } executed: } Execution Count:11 | 11 |
81 | return searchExecutable(searchPaths, executableName); executed: return searchExecutable(searchPaths, executableName); Execution Count:11 | 11 |
82 | } | - |
83 | QString QStandardPaths::displayName(StandardLocation type) | - |
84 | { | - |
85 | switch (type) { | - |
86 | case DesktopLocation: | - |
87 | return QCoreApplication::translate("QStandardPaths", "Desktop"); executed: return QCoreApplication::translate("QStandardPaths", "Desktop"); Execution Count:1 | 1 |
88 | case DocumentsLocation: | - |
89 | return QCoreApplication::translate("QStandardPaths", "Documents"); executed: return QCoreApplication::translate("QStandardPaths", "Documents"); Execution Count:1 | 1 |
90 | case FontsLocation: | - |
91 | return QCoreApplication::translate("QStandardPaths", "Fonts"); executed: return QCoreApplication::translate("QStandardPaths", "Fonts"); Execution Count:1 | 1 |
92 | case ApplicationsLocation: | - |
93 | return QCoreApplication::translate("QStandardPaths", "Applications"); executed: return QCoreApplication::translate("QStandardPaths", "Applications"); Execution Count:1 | 1 |
94 | case MusicLocation: | - |
95 | return QCoreApplication::translate("QStandardPaths", "Music"); executed: return QCoreApplication::translate("QStandardPaths", "Music"); Execution Count:1 | 1 |
96 | case MoviesLocation: | - |
97 | return QCoreApplication::translate("QStandardPaths", "Movies"); executed: return QCoreApplication::translate("QStandardPaths", "Movies"); Execution Count:1 | 1 |
98 | case PicturesLocation: | - |
99 | return QCoreApplication::translate("QStandardPaths", "Pictures"); executed: return QCoreApplication::translate("QStandardPaths", "Pictures"); Execution Count:1 | 1 |
100 | case TempLocation: | - |
101 | return QCoreApplication::translate("QStandardPaths", "Temporary Directory"); executed: return QCoreApplication::translate("QStandardPaths", "Temporary Directory"); Execution Count:1 | 1 |
102 | case HomeLocation: | - |
103 | return QCoreApplication::translate("QStandardPaths", "Home"); executed: return QCoreApplication::translate("QStandardPaths", "Home"); Execution Count:1 | 1 |
104 | case DataLocation: | - |
105 | return QCoreApplication::translate("QStandardPaths", "Application Data"); executed: return QCoreApplication::translate("QStandardPaths", "Application Data"); Execution Count:1 | 1 |
106 | case CacheLocation: | - |
107 | return QCoreApplication::translate("QStandardPaths", "Cache"); never executed: return QCoreApplication::translate("QStandardPaths", "Cache"); | 0 |
108 | case GenericDataLocation: | - |
109 | return QCoreApplication::translate("QStandardPaths", "Shared Data"); never executed: return QCoreApplication::translate("QStandardPaths", "Shared Data"); | 0 |
110 | case RuntimeLocation: | - |
111 | return QCoreApplication::translate("QStandardPaths", "Runtime"); never executed: return QCoreApplication::translate("QStandardPaths", "Runtime"); | 0 |
112 | case ConfigLocation: | - |
113 | return QCoreApplication::translate("QStandardPaths", "Configuration"); never executed: return QCoreApplication::translate("QStandardPaths", "Configuration"); | 0 |
114 | case GenericCacheLocation: | - |
115 | return QCoreApplication::translate("QStandardPaths", "Shared Cache"); never executed: return QCoreApplication::translate("QStandardPaths", "Shared Cache"); | 0 |
116 | case DownloadLocation: | - |
117 | return QCoreApplication::translate("QStandardPaths", "Download"); executed: return QCoreApplication::translate("QStandardPaths", "Download"); Execution Count:1 | 1 |
118 | } | - |
119 | | - |
120 | return QString(); never executed: return QString(); | 0 |
121 | } | - |
122 | static bool qsp_testMode = false; | - |
123 | | - |
124 | void QStandardPaths::enableTestMode(bool testMode) | - |
125 | { | - |
126 | qsp_testMode = testMode; | - |
127 | } executed: } Execution Count:2 | 2 |
128 | bool QStandardPaths::isTestModeEnabled() | - |
129 | { | - |
130 | return qsp_testMode; executed: return qsp_testMode; Execution Count:125 | 125 |
131 | } | - |
132 | | - |
133 | | - |
134 | | - |
135 | | - |
| | |