qstandardpaths.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/io/qstandardpaths.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9static bool existsAsSpecified(const QString &path, QStandardPaths::LocateOptions options)-
10{-
11 if (options & QStandardPaths::LocateDirectory)-
12 return QDir(path).exists();-
13 return QFileInfo(path).isFile();-
14}-
15QString 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) {-
19 const QString path = *dir + QLatin1Char('/') + fileName;-
20 if (existsAsSpecified(path, options))-
21 return path;-
22 }-
23 return QString();-
24}-
25QStringList 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) {-
30 const QString path = *dir + QLatin1Char('/') + fileName;-
31 if (existsAsSpecified(path, options))-
32 result.append(path);-
33 }-
34 return result;-
35}-
36static QString checkExecutable(const QString &path)-
37{-
38 const QFileInfo info(path);-
39 if (info.isBundle())-
40 return info.bundleName();-
41 if (info.isFile() && info.isExecutable())-
42 return QDir::cleanPath(path);-
43 return QString();-
44}-
45-
46static 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: searchPaths) {-
51 const QString candidate = currentDir.absoluteFilePath(searchPath + QLatin1Char('/') + executableName);-
52 const QString absPath = checkExecutable(candidate);-
53 if (!absPath.isEmpty()
!absPath.isEmpty()Description
TRUEevaluated 12 times by 3 tests
Evaluated by:
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_qstandardpaths
FALSEevaluated 225 times by 4 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_qstandardpaths
)
12-225
54 return
executed 12 times by 3 tests: return absPath;
Executed by:
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_qstandardpaths
absPath;
executed 12 times by 3 tests: return absPath;
Executed by:
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_qstandardpaths
12
55 }
executed 225 times by 4 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_qstandardpaths
225
56 return
executed 3 times by 2 tests: return QString();
Executed by:
  • tst_NetworkSelfTest
  • tst_qstandardpaths
QString();
executed 3 times by 2 tests: return QString();
Executed by:
  • tst_NetworkSelfTest
  • tst_qstandardpaths
3
57}-
58QString QStandardPaths::findExecutable(const QString &executableName, const QStringList &paths)-
59{-
60 if (QFileInfo(executableName).isAbsolute()
QFileInfo(exec...).isAbsolute()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qstandardpaths
FALSEevaluated 15 times by 4 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_qstandardpaths
)
2-15
61 return
executed 2 times by 1 test: return checkExecutable(executableName);
Executed by:
  • tst_qstandardpaths
checkExecutable(executableName);
executed 2 times by 1 test: return checkExecutable(executableName);
Executed by:
  • tst_qstandardpaths
2
62-
63 QStringList searchPaths = paths;-
64 if (paths.isEmpty()
paths.isEmpty()Description
TRUEevaluated 15 times by 4 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_qstandardpaths
FALSEnever evaluated
) {
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 (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: rawPaths) {-
70 QString cleanPath = QDir::cleanPath(rawPath);-
71 if (cleanPath.size() > 1
cleanPath.size() > 1Description
TRUEevaluated 255 times by 4 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_qstandardpaths
FALSEnever evaluated
&& cleanPath.endsWith(QLatin1Char('/'))
cleanPath.ends...tin1Char('/'))Description
TRUEnever evaluated
FALSEevaluated 255 times by 4 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_qstandardpaths
)
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:
  • tst_NetworkSelfTest
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_qstandardpaths
255
75 }
executed 15 times by 4 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_qstandardpaths
15
76 return
executed 15 times by 4 tests: return searchExecutable(searchPaths, executableName);
Executed by:
  • tst_NetworkSelfTest
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_qstandardpaths
searchExecutable(searchPaths, executableName);
executed 15 times by 4 tests: return searchExecutable(searchPaths, executableName);
Executed by:
  • tst_NetworkSelfTest
  • tst_QIcon
  • tst_QMimeDatabase
  • tst_qstandardpaths
15
77}-
78QString QStandardPaths::displayName(StandardLocation type)-
79{-
80 switch (type) {-
81 case DesktopLocation:-
82 return QCoreApplication::translate("QStandardPaths", "Desktop");-
83 case DocumentsLocation:-
84 return QCoreApplication::translate("QStandardPaths", "Documents");-
85 case FontsLocation:-
86 return QCoreApplication::translate("QStandardPaths", "Fonts");-
87 case ApplicationsLocation:-
88 return QCoreApplication::translate("QStandardPaths", "Applications");-
89 case MusicLocation:-
90 return QCoreApplication::translate("QStandardPaths", "Music");-
91 case MoviesLocation:-
92 return QCoreApplication::translate("QStandardPaths", "Movies");-
93 case PicturesLocation:-
94 return QCoreApplication::translate("QStandardPaths", "Pictures");-
95 case TempLocation:-
96 return QCoreApplication::translate("QStandardPaths", "Temporary Directory");-
97 case HomeLocation:-
98 return QCoreApplication::translate("QStandardPaths", "Home");-
99 case CacheLocation:-
100 return QCoreApplication::translate("QStandardPaths", "Cache");-
101 case GenericDataLocation:-
102 return QCoreApplication::translate("QStandardPaths", "Shared Data");-
103 case RuntimeLocation:-
104 return QCoreApplication::translate("QStandardPaths", "Runtime");-
105 case ConfigLocation:-
106 return QCoreApplication::translate("QStandardPaths", "Configuration");-
107 case GenericConfigLocation:-
108 return QCoreApplication::translate("QStandardPaths", "Shared Configuration");-
109 case GenericCacheLocation:-
110 return QCoreApplication::translate("QStandardPaths", "Shared Cache");-
111 case DownloadLocation:-
112 return QCoreApplication::translate("QStandardPaths", "Download");-
113 case AppDataLocation:-
114 case AppLocalDataLocation:-
115 return QCoreApplication::translate("QStandardPaths", "Application Data");-
116 case AppConfigLocation:-
117 return QCoreApplication::translate("QStandardPaths", "Application Configuration");-
118 }-
119-
120 return QString();-
121}-
122static bool qsp_testMode = false;-
123-
124-
125void QStandardPaths::enableTestMode(bool testMode)-
126{-
127 qsp_testMode = testMode;-
128}-
129-
130-
131void QStandardPaths::setTestModeEnabled(bool testMode)-
132{-
133 qsp_testMode = testMode;-
134}-
135bool QStandardPaths::isTestModeEnabled()-
136{-
137 return qsp_testMode;-
138}-
139-
140-
141-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9