qstandardpaths_unix.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/io/qstandardpaths_unix.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtCore module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qstandardpaths.h"-
35#include <qdir.h>-
36#include <qfile.h>-
37#include <qhash.h>-
38#include <qtextstream.h>-
39#include <private/qfilesystemengine_p.h>-
40#include <errno.h>-
41#include <stdlib.h>-
42-
43#ifndef QT_BOOTSTRAPPED-
44#include <qcoreapplication.h>-
45#endif-
46-
47#ifndef QT_NO_STANDARDPATHS-
48-
49QT_BEGIN_NAMESPACE-
50-
51static void appendOrganizationAndApp(QString &path)-
52{-
53#ifndef QT_BOOTSTRAPPED-
54 const QString org = QCoreApplication::organizationName();-
55 if (!org.isEmpty())
!org.isEmpty()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qstandardpaths
FALSEevaluated 30 times by 1 test
Evaluated by:
  • tst_qstandardpaths
8-30
56 path += QLatin1Char('/') + org;
executed 8 times by 1 test: path += QLatin1Char('/') + org;
Executed by:
  • tst_qstandardpaths
8
57 const QString appName = QCoreApplication::applicationName();-
58 if (!appName.isEmpty())
!appName.isEmpty()Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • tst_qstandardpaths
FALSEnever evaluated
0-38
59 path += QLatin1Char('/') + appName;
executed 38 times by 1 test: path += QLatin1Char('/') + appName;
Executed by:
  • tst_qstandardpaths
38
60#else-
61 Q_UNUSED(path);-
62#endif-
63}
executed 38 times by 1 test: end of block
Executed by:
  • tst_qstandardpaths
38
64-
65QString QStandardPaths::writableLocation(StandardLocation type)-
66{-
67 switch (type) {-
68 case HomeLocation:
executed 5 times by 1 test: case HomeLocation:
Executed by:
  • tst_qstandardpaths
5
69 return QDir::homePath();
executed 5 times by 1 test: return QDir::homePath();
Executed by:
  • tst_qstandardpaths
5
70 case TempLocation:
executed 5 times by 1 test: case TempLocation:
Executed by:
  • tst_qstandardpaths
5
71 return QDir::tempPath();
executed 5 times by 1 test: return QDir::tempPath();
Executed by:
  • tst_qstandardpaths
5
72 case CacheLocation:
executed 6 times by 1 test: case CacheLocation:
Executed by:
  • tst_qstandardpaths
6
73 case GenericCacheLocation:
executed 8 times by 1 test: case GenericCacheLocation:
Executed by:
  • tst_qstandardpaths
8
74 {-
75 // http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html-
76 QString xdgCacheHome = QFile::decodeName(qgetenv("XDG_CACHE_HOME"));-
77 if (isTestModeEnabled())
isTestModeEnabled()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qstandardpaths
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_qstandardpaths
4-10
78 xdgCacheHome = QDir::homePath() + QLatin1String("/.qttest/cache");
executed 4 times by 1 test: xdgCacheHome = QDir::homePath() + QLatin1String("/.qttest/cache");
Executed by:
  • tst_qstandardpaths
4
79 if (xdgCacheHome.isEmpty())
xdgCacheHome.isEmpty()Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qstandardpaths
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qstandardpaths
4-10
80 xdgCacheHome = QDir::homePath() + QLatin1String("/.cache");
executed 10 times by 1 test: xdgCacheHome = QDir::homePath() + QLatin1String("/.cache");
Executed by:
  • tst_qstandardpaths
10
81 if (type == QStandardPaths::CacheLocation)
type == QStand...:CacheLocationDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qstandardpaths
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qstandardpaths
6-8
82 appendOrganizationAndApp(xdgCacheHome);
executed 6 times by 1 test: appendOrganizationAndApp(xdgCacheHome);
Executed by:
  • tst_qstandardpaths
6
83 return xdgCacheHome;
executed 14 times by 1 test: return xdgCacheHome;
Executed by:
  • tst_qstandardpaths
14
84 }-
85 case AppDataLocation:
executed 5 times by 1 test: case AppDataLocation:
Executed by:
  • tst_qstandardpaths
5
86 case AppLocalDataLocation:
executed 13 times by 1 test: case AppLocalDataLocation:
Executed by:
  • tst_qstandardpaths
13
87 case GenericDataLocation:
executed 165 times by 5 tests: case GenericDataLocation:
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qdesktopservices
  • tst_qmimetype
  • tst_qstandardpaths
165
88 {-
89 QString xdgDataHome = QFile::decodeName(qgetenv("XDG_DATA_HOME"));-
90 if (isTestModeEnabled())
isTestModeEnabled()Description
TRUEevaluated 143 times by 2 tests
Evaluated by:
  • tst_QMimeDatabase
  • tst_qstandardpaths
FALSEevaluated 40 times by 4 tests
Evaluated by:
  • tst_QDebug
  • tst_qdesktopservices
  • tst_qmimetype
  • tst_qstandardpaths
40-143
91 xdgDataHome = QDir::homePath() + QLatin1String("/.qttest/share");
executed 143 times by 2 tests: xdgDataHome = QDir::homePath() + QLatin1String("/.qttest/share");
Executed by:
  • tst_QMimeDatabase
  • tst_qstandardpaths
143
92 if (xdgDataHome.isEmpty())
xdgDataHome.isEmpty()Description
TRUEevaluated 29 times by 4 tests
Evaluated by:
  • tst_QDebug
  • tst_qdesktopservices
  • tst_qmimetype
  • tst_qstandardpaths
FALSEevaluated 154 times by 2 tests
Evaluated by:
  • tst_QMimeDatabase
  • tst_qstandardpaths
29-154
93 xdgDataHome = QDir::homePath() + QLatin1String("/.local/share");
executed 29 times by 4 tests: xdgDataHome = QDir::homePath() + QLatin1String("/.local/share");
Executed by:
  • tst_QDebug
  • tst_qdesktopservices
  • tst_qmimetype
  • tst_qstandardpaths
29
94 if (type == AppDataLocation || type == AppLocalDataLocation)
type == AppDataLocationDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_qstandardpaths
FALSEevaluated 178 times by 5 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qdesktopservices
  • tst_qmimetype
  • tst_qstandardpaths
type == AppLocalDataLocationDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • tst_qstandardpaths
FALSEevaluated 165 times by 5 tests
Evaluated by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qdesktopservices
  • tst_qmimetype
  • tst_qstandardpaths
5-178
95 appendOrganizationAndApp(xdgDataHome);
executed 18 times by 1 test: appendOrganizationAndApp(xdgDataHome);
Executed by:
  • tst_qstandardpaths
18
96 return xdgDataHome;
executed 183 times by 5 tests: return xdgDataHome;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qdesktopservices
  • tst_qmimetype
  • tst_qstandardpaths
183
97 }-
98 case ConfigLocation:
executed 16 times by 1 test: case ConfigLocation:
Executed by:
  • tst_qstandardpaths
16
99 case GenericConfigLocation:
executed 888 times by 31 tests: case GenericConfigLocation:
Executed by:
  • tst_QApplication
  • tst_QColorDialog
  • tst_QCommandLineParser
  • tst_QCoreApplication
  • tst_QDBusConnectionNoBus
  • tst_QDBusConnectionNoLibDBus1
  • tst_QDBusConnection_Delayed
  • tst_QDnsLookup_Appless
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QGlobal
  • tst_QGraphicsProxyWidget
  • tst_QGuiApplication
  • tst_QLoggingRegistry
  • tst_QNetworkConfigurationManager
  • tst_QSettings
  • tst_QSql
  • tst_QTextFormat
  • tst_languageChange
  • tst_qapplication - unknown status
  • tst_qdbusabstractadaptor - unknown status
  • tst_qdbusabstractinterface - unknown status
  • tst_qdbusinterface - unknown status
  • tst_qdbusmarshall - unknown status
  • tst_qlogging - unknown status
  • ...
888
100 case AppConfigLocation:
executed 5 times by 1 test: case AppConfigLocation:
Executed by:
  • tst_qstandardpaths
5
101 {-
102 // http://standards.freedesktop.org/basedir-spec/latest/-
103 QString xdgConfigHome = QFile::decodeName(qgetenv("XDG_CONFIG_HOME"));-
104 if (isTestModeEnabled())
isTestModeEnabled()Description
TRUEevaluated 12 times by 5 tests
Evaluated by:
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QLoggingRegistry
  • tst_QSettings
  • tst_qstandardpaths
FALSEevaluated 897 times by 27 tests
Evaluated by:
  • tst_QApplication
  • tst_QColorDialog
  • tst_QCommandLineParser
  • tst_QCoreApplication
  • tst_QDBusConnectionNoBus
  • tst_QDBusConnectionNoLibDBus1
  • tst_QDBusConnection_Delayed
  • tst_QDnsLookup_Appless
  • tst_QGlobal
  • tst_QGraphicsProxyWidget
  • tst_QGuiApplication
  • tst_QNetworkConfigurationManager
  • tst_QSql
  • tst_QTextFormat
  • tst_languageChange
  • tst_qapplication - unknown status
  • tst_qdbusabstractadaptor - unknown status
  • tst_qdbusabstractinterface - unknown status
  • tst_qdbusinterface - unknown status
  • tst_qdbusmarshall - unknown status
  • tst_qlogging - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsharedmemory - unknown status
  • tst_qstandardpaths
  • ...
12-897
105 xdgConfigHome = QDir::homePath() + QLatin1String("/.qttest/config");
executed 12 times by 5 tests: xdgConfigHome = QDir::homePath() + QLatin1String("/.qttest/config");
Executed by:
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QLoggingRegistry
  • tst_QSettings
  • tst_qstandardpaths
12
106 if (xdgConfigHome.isEmpty())
xdgConfigHome.isEmpty()Description
TRUEevaluated 888 times by 27 tests
Evaluated by:
  • tst_QApplication
  • tst_QColorDialog
  • tst_QCommandLineParser
  • tst_QCoreApplication
  • tst_QDBusConnectionNoBus
  • tst_QDBusConnectionNoLibDBus1
  • tst_QDBusConnection_Delayed
  • tst_QDnsLookup_Appless
  • tst_QGlobal
  • tst_QGraphicsProxyWidget
  • tst_QGuiApplication
  • tst_QNetworkConfigurationManager
  • tst_QSql
  • tst_QTextFormat
  • tst_languageChange
  • tst_qapplication - unknown status
  • tst_qdbusabstractadaptor - unknown status
  • tst_qdbusabstractinterface - unknown status
  • tst_qdbusinterface - unknown status
  • tst_qdbusmarshall - unknown status
  • tst_qlogging - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsharedmemory - unknown status
  • tst_qstandardpaths
  • ...
FALSEevaluated 21 times by 5 tests
Evaluated by:
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QLoggingRegistry
  • tst_QSettings
  • tst_qstandardpaths
21-888
107 xdgConfigHome = QDir::homePath() + QLatin1String("/.config");
executed 888 times by 27 tests: xdgConfigHome = QDir::homePath() + QLatin1String("/.config");
Executed by:
  • tst_QApplication
  • tst_QColorDialog
  • tst_QCommandLineParser
  • tst_QCoreApplication
  • tst_QDBusConnectionNoBus
  • tst_QDBusConnectionNoLibDBus1
  • tst_QDBusConnection_Delayed
  • tst_QDnsLookup_Appless
  • tst_QGlobal
  • tst_QGraphicsProxyWidget
  • tst_QGuiApplication
  • tst_QNetworkConfigurationManager
  • tst_QSql
  • tst_QTextFormat
  • tst_languageChange
  • tst_qapplication - unknown status
  • tst_qdbusabstractadaptor - unknown status
  • tst_qdbusabstractinterface - unknown status
  • tst_qdbusinterface - unknown status
  • tst_qdbusmarshall - unknown status
  • tst_qlogging - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsharedmemory - unknown status
  • tst_qstandardpaths
  • ...
888
108 if (type == AppConfigLocation)
type == AppConfigLocationDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_qstandardpaths
FALSEevaluated 904 times by 31 tests
Evaluated by:
  • tst_QApplication
  • tst_QColorDialog
  • tst_QCommandLineParser
  • tst_QCoreApplication
  • tst_QDBusConnectionNoBus
  • tst_QDBusConnectionNoLibDBus1
  • tst_QDBusConnection_Delayed
  • tst_QDnsLookup_Appless
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QGlobal
  • tst_QGraphicsProxyWidget
  • tst_QGuiApplication
  • tst_QLoggingRegistry
  • tst_QNetworkConfigurationManager
  • tst_QSettings
  • tst_QSql
  • tst_QTextFormat
  • tst_languageChange
  • tst_qapplication - unknown status
  • tst_qdbusabstractadaptor - unknown status
  • tst_qdbusabstractinterface - unknown status
  • tst_qdbusinterface - unknown status
  • tst_qdbusmarshall - unknown status
  • tst_qlogging - unknown status
  • ...
5-904
109 appendOrganizationAndApp(xdgConfigHome);
executed 5 times by 1 test: appendOrganizationAndApp(xdgConfigHome);
Executed by:
  • tst_qstandardpaths
5
110 return xdgConfigHome;
executed 909 times by 31 tests: return xdgConfigHome;
Executed by:
  • tst_QApplication
  • tst_QColorDialog
  • tst_QCommandLineParser
  • tst_QCoreApplication
  • tst_QDBusConnectionNoBus
  • tst_QDBusConnectionNoLibDBus1
  • tst_QDBusConnection_Delayed
  • tst_QDnsLookup_Appless
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QGlobal
  • tst_QGraphicsProxyWidget
  • tst_QGuiApplication
  • tst_QLoggingRegistry
  • tst_QNetworkConfigurationManager
  • tst_QSettings
  • tst_QSql
  • tst_QTextFormat
  • tst_languageChange
  • tst_qapplication - unknown status
  • tst_qdbusabstractadaptor - unknown status
  • tst_qdbusabstractinterface - unknown status
  • tst_qdbusinterface - unknown status
  • tst_qdbusmarshall - unknown status
  • tst_qlogging - unknown status
  • ...
909
111 }-
112 case RuntimeLocation:
executed 8 times by 1 test: case RuntimeLocation:
Executed by:
  • tst_qstandardpaths
8
113 {-
114 const uid_t myUid = geteuid();-
115 // http://standards.freedesktop.org/basedir-spec/latest/-
116 QFileInfo fileInfo;-
117 QString xdgRuntimeDir = QFile::decodeName(qgetenv("XDG_RUNTIME_DIR"));-
118 if (xdgRuntimeDir.isEmpty()) {
xdgRuntimeDir.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qstandardpaths
0-8
119 const QString userName = QFileSystemEngine::resolveUserName(myUid);-
120 xdgRuntimeDir = QDir::tempPath() + QLatin1String("/runtime-") + userName;-
121 fileInfo.setFile(xdgRuntimeDir);-
122 if (!fileInfo.isDir()) {
!fileInfo.isDir()Description
TRUEnever evaluated
FALSEnever evaluated
0
123 if (!QDir().mkdir(xdgRuntimeDir)) {
!QDir().mkdir(xdgRuntimeDir)Description
TRUEnever evaluated
FALSEnever evaluated
0
124 qWarning("QStandardPaths: error creating runtime directory %s: %s", qPrintable(xdgRuntimeDir), qPrintable(qt_error_string(errno)));-
125 return QString();
never executed: return QString();
0
126 }-
127 }
never executed: end of block
0
128 qWarning("QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '%s'", qPrintable(xdgRuntimeDir));-
129 } else {
never executed: end of block
0
130 fileInfo.setFile(xdgRuntimeDir);-
131 if (!fileInfo.exists()) {
!fileInfo.exists()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qstandardpaths
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_qstandardpaths
1-7
132 qWarning("QStandardPaths: XDG_RUNTIME_DIR points to non-existing path '%s', "-
133 "please create it with 0700 permissions.", qPrintable(xdgRuntimeDir));-
134 return QString();
executed 1 time by 1 test: return QString();
Executed by:
  • tst_qstandardpaths
1
135 }-
136 if (!fileInfo.isDir()) {
!fileInfo.isDir()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qstandardpaths
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qstandardpaths
1-6
137 qWarning("QStandardPaths: XDG_RUNTIME_DIR points to '%s' which is not a directory",-
138 qPrintable(xdgRuntimeDir));-
139 return QString();
executed 1 time by 1 test: return QString();
Executed by:
  • tst_qstandardpaths
1
140 }-
141 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_qstandardpaths
6
142 // "The directory MUST be owned by the user"-
143 if (fileInfo.ownerId() != myUid) {
fileInfo.ownerId() != myUidDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qstandardpaths
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_qstandardpaths
1-5
144 qWarning("QStandardPaths: wrong ownership on runtime directory %s, %d instead of %d", qPrintable(xdgRuntimeDir),-
145 fileInfo.ownerId(), myUid);-
146 return QString();
executed 1 time by 1 test: return QString();
Executed by:
  • tst_qstandardpaths
1
147 }-
148 // "and he MUST be the only one having read and write access to it. Its Unix access mode MUST be 0700."-
149 // since the current user is the owner, set both xxxUser and xxxOwner-
150 const QFile::Permissions wantedPerms = QFile::ReadUser | QFile::WriteUser | QFile::ExeUser-
151 | QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner;-
152 if (fileInfo.permissions() != wantedPerms) {
fileInfo.permi...!= wantedPermsDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qstandardpaths
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qstandardpaths
1-4
153 QFile file(xdgRuntimeDir);-
154 if (!file.setPermissions(wantedPerms)) {
!file.setPermi...s(wantedPerms)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qstandardpaths
0-1
155 qWarning("QStandardPaths: could not set correct permissions on runtime directory %s: %s",-
156 qPrintable(xdgRuntimeDir), qPrintable(file.errorString()));-
157 return QString();
never executed: return QString();
0
158 }-
159 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_qstandardpaths
1
160 return xdgRuntimeDir;
executed 5 times by 1 test: return xdgRuntimeDir;
Executed by:
  • tst_qstandardpaths
5
161 }-
162 default:
executed 45 times by 3 tests: default:
Executed by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
45
163 break;
executed 45 times by 3 tests: break;
Executed by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
45
164 }-
165-
166#ifndef QT_BOOTSTRAPPED-
167 // http://www.freedesktop.org/wiki/Software/xdg-user-dirs-
168 QString xdgConfigHome = QFile::decodeName(qgetenv("XDG_CONFIG_HOME"));-
169 if (xdgConfigHome.isEmpty())
xdgConfigHome.isEmpty()Description
TRUEevaluated 43 times by 3 tests
Evaluated by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qstandardpaths
2-43
170 xdgConfigHome = QDir::homePath() + QLatin1String("/.config");
executed 43 times by 3 tests: xdgConfigHome = QDir::homePath() + QLatin1String("/.config");
Executed by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
43
171 QFile file(xdgConfigHome + QLatin1String("/user-dirs.dirs"));-
172 if (!isTestModeEnabled() && file.open(QIODevice::ReadOnly)) {
!isTestModeEnabled()Description
TRUEevaluated 45 times by 3 tests
Evaluated by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
FALSEnever evaluated
file.open(QIODevice::ReadOnly)Description
TRUEevaluated 43 times by 3 tests
Evaluated by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qstandardpaths
0-45
173 QHash<QString, QString> lines;-
174 QTextStream stream(&file);-
175 // Only look for lines like: XDG_DESKTOP_DIR="$HOME/Desktop"-
176 QRegExp exp(QLatin1String("^XDG_(.*)_DIR=(.*)$"));-
177 while (!stream.atEnd()) {
!stream.atEnd()Description
TRUEevaluated 645 times by 3 tests
Evaluated by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
FALSEevaluated 43 times by 3 tests
Evaluated by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
43-645
178 const QString &line = stream.readLine();-
179 if (exp.indexIn(line) != -1) {
exp.indexIn(line) != -1Description
TRUEevaluated 344 times by 3 tests
Evaluated by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
FALSEevaluated 301 times by 3 tests
Evaluated by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
301-344
180 const QStringList lst = exp.capturedTexts();-
181 const QString key = lst.at(1);-
182 QString value = lst.at(2);-
183 if (value.length() > 2
value.length() > 2Description
TRUEevaluated 344 times by 3 tests
Evaluated by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
FALSEnever evaluated
0-344
184 && value.startsWith(QLatin1Char('\"'))
value.startsWi...in1Char('\"'))Description
TRUEevaluated 344 times by 3 tests
Evaluated by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
FALSEnever evaluated
0-344
185 && value.endsWith(QLatin1Char('\"')))
value.endsWith...in1Char('\"'))Description
TRUEevaluated 344 times by 3 tests
Evaluated by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
FALSEnever evaluated
0-344
186 value = value.mid(1, value.length() - 2);
executed 344 times by 3 tests: value = value.mid(1, value.length() - 2);
Executed by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
344
187 // Store the key and value: "DESKTOP", "$HOME/Desktop"-
188 lines[key] = value;-
189 }
executed 344 times by 3 tests: end of block
Executed by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
344
190 }
executed 645 times by 3 tests: end of block
Executed by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
645
191-
192 QString key;-
193 switch (type) {-
194 case DesktopLocation:
executed 5 times by 1 test: case DesktopLocation:
Executed by:
  • tst_qstandardpaths
5
195 key = QLatin1String("DESKTOP");-
196 break;
executed 5 times by 1 test: break;
Executed by:
  • tst_qstandardpaths
5
197 case DocumentsLocation:
executed 7 times by 2 tests: case DocumentsLocation:
Executed by:
  • tst_QFileSystemModel
  • tst_qstandardpaths
7
198 key = QLatin1String("DOCUMENTS");-
199 break;
executed 7 times by 2 tests: break;
Executed by:
  • tst_QFileSystemModel
  • tst_qstandardpaths
7
200 case PicturesLocation:
executed 5 times by 1 test: case PicturesLocation:
Executed by:
  • tst_qstandardpaths
5
201 key = QLatin1String("PICTURES");-
202 break;
executed 5 times by 1 test: break;
Executed by:
  • tst_qstandardpaths
5
203 case MusicLocation:
executed 5 times by 1 test: case MusicLocation:
Executed by:
  • tst_qstandardpaths
5
204 key = QLatin1String("MUSIC");-
205 break;
executed 5 times by 1 test: break;
Executed by:
  • tst_qstandardpaths
5
206 case MoviesLocation:
executed 5 times by 1 test: case MoviesLocation:
Executed by:
  • tst_qstandardpaths
5
207 key = QLatin1String("VIDEOS");-
208 break;
executed 5 times by 1 test: break;
Executed by:
  • tst_qstandardpaths
5
209 case DownloadLocation:
executed 6 times by 2 tests: case DownloadLocation:
Executed by:
  • tst_QTemporaryDir
  • tst_qstandardpaths
6
210 key = QLatin1String("DOWNLOAD");-
211 break;
executed 6 times by 2 tests: break;
Executed by:
  • tst_QTemporaryDir
  • tst_qstandardpaths
6
212 default:
executed 10 times by 1 test: default:
Executed by:
  • tst_qstandardpaths
10
213 break;
executed 10 times by 1 test: break;
Executed by:
  • tst_qstandardpaths
10
214 }-
215 if (!key.isEmpty()) {
!key.isEmpty()Description
TRUEevaluated 33 times by 3 tests
Evaluated by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_qstandardpaths
10-33
216 QString value = lines.value(key);-
217 if (!value.isEmpty()) {
!value.isEmpty()Description
TRUEevaluated 33 times by 3 tests
Evaluated by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
FALSEnever evaluated
0-33
218 // value can start with $HOME-
219 if (value.startsWith(QLatin1String("$HOME")))
value.startsWi...ring("$HOME"))Description
TRUEevaluated 33 times by 3 tests
Evaluated by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
FALSEnever evaluated
0-33
220 value = QDir::homePath() + value.mid(5);
executed 33 times by 3 tests: value = QDir::homePath() + value.mid(5);
Executed by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
33
221 if (value.length() > 1 && value.endsWith(QLatin1Char('/')))
value.length() > 1Description
TRUEevaluated 33 times by 3 tests
Evaluated by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
FALSEnever evaluated
value.endsWith...tin1Char('/'))Description
TRUEnever evaluated
FALSEevaluated 33 times by 3 tests
Evaluated by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
0-33
222 value.chop(1);
never executed: value.chop(1);
0
223 return value;
executed 33 times by 3 tests: return value;
Executed by:
  • tst_QFileSystemModel
  • tst_QTemporaryDir
  • tst_qstandardpaths
33
224 }-
225 }
never executed: end of block
0
226 }
executed 10 times by 1 test: end of block
Executed by:
  • tst_qstandardpaths
10
227#endif-
228-
229 QString path;-
230 switch (type) {-
231 case DesktopLocation:
never executed: case DesktopLocation:
0
232 path = QDir::homePath() + QLatin1String("/Desktop");-
233 break;
never executed: break;
0
234 case DocumentsLocation:
never executed: case DocumentsLocation:
0
235 path = QDir::homePath() + QLatin1String("/Documents");-
236 break;
never executed: break;
0
237 case PicturesLocation:
never executed: case PicturesLocation:
0
238 path = QDir::homePath() + QLatin1String("/Pictures");-
239 break;
never executed: break;
0
240-
241 case FontsLocation:
executed 5 times by 1 test: case FontsLocation:
Executed by:
  • tst_qstandardpaths
5
242 path = QDir::homePath() + QLatin1String("/.fonts");-
243 break;
executed 5 times by 1 test: break;
Executed by:
  • tst_qstandardpaths
5
244-
245 case MusicLocation:
never executed: case MusicLocation:
0
246 path = QDir::homePath() + QLatin1String("/Music");-
247 break;
never executed: break;
0
248-
249 case MoviesLocation:
never executed: case MoviesLocation:
0
250 path = QDir::homePath() + QLatin1String("/Videos");-
251 break;
never executed: break;
0
252 case DownloadLocation:
never executed: case DownloadLocation:
0
253 path = QDir::homePath() + QLatin1String("/Downloads");-
254 break;
never executed: break;
0
255 case ApplicationsLocation:
executed 7 times by 1 test: case ApplicationsLocation:
Executed by:
  • tst_qstandardpaths
7
256 path = writableLocation(GenericDataLocation) + QLatin1String("/applications");-
257 break;
executed 7 times by 1 test: break;
Executed by:
  • tst_qstandardpaths
7
258-
259 default:
never executed: default:
0
260 break;
never executed: break;
0
261 }-
262-
263 return path;
executed 12 times by 1 test: return path;
Executed by:
  • tst_qstandardpaths
12
264}-
265-
266static QStringList xdgDataDirs()-
267{-
268 QStringList dirs;-
269 // http://standards.freedesktop.org/basedir-spec/latest/-
270 QString xdgDataDirsEnv = QFile::decodeName(qgetenv("XDG_DATA_DIRS"));-
271 if (xdgDataDirsEnv.isEmpty()) {
xdgDataDirsEnv.isEmpty()Description
TRUEevaluated 11 times by 2 tests
Evaluated by:
  • tst_QDebug
  • tst_qstandardpaths
FALSEevaluated 141 times by 3 tests
Evaluated by:
  • tst_QMimeDatabase
  • tst_qmimetype
  • tst_qstandardpaths
11-141
272 dirs.append(QString::fromLatin1("/usr/local/share"));-
273 dirs.append(QString::fromLatin1("/usr/share"));-
274 } else {
executed 11 times by 2 tests: end of block
Executed by:
  • tst_QDebug
  • tst_qstandardpaths
11
275 dirs = xdgDataDirsEnv.split(QLatin1Char(':'), QString::SkipEmptyParts);-
276-
277 // Normalize paths, skip relative paths-
278 QMutableListIterator<QString> it(dirs);-
279 while (it.hasNext()) {
it.hasNext()Description
TRUEevaluated 142 times by 3 tests
Evaluated by:
  • tst_QMimeDatabase
  • tst_qmimetype
  • tst_qstandardpaths
FALSEevaluated 141 times by 3 tests
Evaluated by:
  • tst_QMimeDatabase
  • tst_qmimetype
  • tst_qstandardpaths
141-142
280 const QString dir = it.next();-
281 if (!dir.startsWith(QLatin1Char('/')))
!dir.startsWit...tin1Char('/'))Description
TRUEevaluated 2 times by 2 tests
Evaluated by:
  • tst_qmimetype
  • tst_qstandardpaths
FALSEevaluated 140 times by 2 tests
Evaluated by:
  • tst_QMimeDatabase
  • tst_qstandardpaths
2-140
282 it.remove();
executed 2 times by 2 tests: it.remove();
Executed by:
  • tst_qmimetype
  • tst_qstandardpaths
2
283 else-
284 it.setValue(QDir::cleanPath(dir));
executed 140 times by 2 tests: it.setValue(QDir::cleanPath(dir));
Executed by:
  • tst_QMimeDatabase
  • tst_qstandardpaths
140
285 }-
286-
287 // Remove duplicates from the list, there's no use for duplicated-
288 // paths in XDG_DATA_DIRS - if it's not found in the given-
289 // directory the first time, it won't be there the second time.-
290 // Plus duplicate paths causes problems for example for mimetypes,-
291 // where duplicate paths here lead to duplicated mime types returned-
292 // for a file, eg "text/plain,text/plain" instead of "text/plain"-
293 dirs.removeDuplicates();-
294 }
executed 141 times by 3 tests: end of block
Executed by:
  • tst_QMimeDatabase
  • tst_qmimetype
  • tst_qstandardpaths
141
295 return dirs;
executed 152 times by 4 tests: return dirs;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qmimetype
  • tst_qstandardpaths
152
296}-
297-
298static QStringList xdgConfigDirs()-
299{-
300 QStringList dirs;-
301 // http://standards.freedesktop.org/basedir-spec/latest/-
302 const QString xdgConfigDirs = QFile::decodeName(qgetenv("XDG_CONFIG_DIRS"));-
303 if (xdgConfigDirs.isEmpty())
xdgConfigDirs.isEmpty()Description
TRUEevaluated 876 times by 24 tests
Evaluated by:
  • tst_QApplication
  • tst_QCommandLineParser
  • tst_QCoreApplication
  • tst_QDBusConnectionNoBus
  • tst_QDBusConnectionNoLibDBus1
  • tst_QDBusConnection_Delayed
  • tst_QDnsLookup_Appless
  • tst_QGlobal
  • tst_QGuiApplication
  • tst_QLoggingRegistry
  • tst_QNetworkConfigurationManager
  • tst_QSql
  • tst_qapplication - unknown status
  • tst_qdbusabstractadaptor - unknown status
  • tst_qdbusabstractinterface - unknown status
  • tst_qdbusinterface - unknown status
  • tst_qdbusmarshall - unknown status
  • tst_qlogging - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsharedmemory - unknown status
  • tst_qstandardpaths
  • tst_qsystemsemaphore - unknown status
  • tst_selftests - unknown status
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qstandardpaths
6-876
304 dirs.append(QString::fromLatin1("/etc/xdg"));
executed 876 times by 24 tests: dirs.append(QString::fromLatin1("/etc/xdg"));
Executed by:
  • tst_QApplication
  • tst_QCommandLineParser
  • tst_QCoreApplication
  • tst_QDBusConnectionNoBus
  • tst_QDBusConnectionNoLibDBus1
  • tst_QDBusConnection_Delayed
  • tst_QDnsLookup_Appless
  • tst_QGlobal
  • tst_QGuiApplication
  • tst_QLoggingRegistry
  • tst_QNetworkConfigurationManager
  • tst_QSql
  • tst_qapplication - unknown status
  • tst_qdbusabstractadaptor - unknown status
  • tst_qdbusabstractinterface - unknown status
  • tst_qdbusinterface - unknown status
  • tst_qdbusmarshall - unknown status
  • tst_qlogging - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsharedmemory - unknown status
  • tst_qstandardpaths
  • tst_qsystemsemaphore - unknown status
  • tst_selftests - unknown status
876
305 else-
306 dirs = xdgConfigDirs.split(QLatin1Char(':'));
executed 6 times by 1 test: dirs = xdgConfigDirs.split(QLatin1Char(':'));
Executed by:
  • tst_qstandardpaths
6
307 return dirs;
executed 882 times by 24 tests: return dirs;
Executed by:
  • tst_QApplication
  • tst_QCommandLineParser
  • tst_QCoreApplication
  • tst_QDBusConnectionNoBus
  • tst_QDBusConnectionNoLibDBus1
  • tst_QDBusConnection_Delayed
  • tst_QDnsLookup_Appless
  • tst_QGlobal
  • tst_QGuiApplication
  • tst_QLoggingRegistry
  • tst_QNetworkConfigurationManager
  • tst_QSql
  • tst_qapplication - unknown status
  • tst_qdbusabstractadaptor - unknown status
  • tst_qdbusabstractinterface - unknown status
  • tst_qdbusinterface - unknown status
  • tst_qdbusmarshall - unknown status
  • tst_qlogging - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsharedmemory - unknown status
  • tst_qstandardpaths
  • tst_qsystemsemaphore - unknown status
  • tst_selftests - unknown status
882
308}-
309-
310QStringList QStandardPaths::standardLocations(StandardLocation type)-
311{-
312 QStringList dirs;-
313 switch (type) {-
314 case ConfigLocation:
executed 9 times by 1 test: case ConfigLocation:
Executed by:
  • tst_qstandardpaths
9
315 case GenericConfigLocation:
executed 872 times by 24 tests: case GenericConfigLocation:
Executed by:
  • tst_QApplication
  • tst_QCommandLineParser
  • tst_QCoreApplication
  • tst_QDBusConnectionNoBus
  • tst_QDBusConnectionNoLibDBus1
  • tst_QDBusConnection_Delayed
  • tst_QDnsLookup_Appless
  • tst_QGlobal
  • tst_QGuiApplication
  • tst_QLoggingRegistry
  • tst_QNetworkConfigurationManager
  • tst_QSql
  • tst_qapplication - unknown status
  • tst_qdbusabstractadaptor - unknown status
  • tst_qdbusabstractinterface - unknown status
  • tst_qdbusinterface - unknown status
  • tst_qdbusmarshall - unknown status
  • tst_qlogging - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsharedmemory - unknown status
  • tst_qstandardpaths
  • tst_qsystemsemaphore - unknown status
  • tst_selftests - unknown status
872
316 dirs = xdgConfigDirs();-
317 break;
executed 881 times by 24 tests: break;
Executed by:
  • tst_QApplication
  • tst_QCommandLineParser
  • tst_QCoreApplication
  • tst_QDBusConnectionNoBus
  • tst_QDBusConnectionNoLibDBus1
  • tst_QDBusConnection_Delayed
  • tst_QDnsLookup_Appless
  • tst_QGlobal
  • tst_QGuiApplication
  • tst_QLoggingRegistry
  • tst_QNetworkConfigurationManager
  • tst_QSql
  • tst_qapplication - unknown status
  • tst_qdbusabstractadaptor - unknown status
  • tst_qdbusabstractinterface - unknown status
  • tst_qdbusinterface - unknown status
  • tst_qdbusmarshall - unknown status
  • tst_qlogging - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsharedmemory - unknown status
  • tst_qstandardpaths
  • tst_qsystemsemaphore - unknown status
  • tst_selftests - unknown status
881
318 case AppConfigLocation:
executed 1 time by 1 test: case AppConfigLocation:
Executed by:
  • tst_qstandardpaths
1
319 dirs = xdgConfigDirs();-
320 for (int i = 0; i < dirs.count(); ++i)
i < dirs.count()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qstandardpaths
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qstandardpaths
1
321 appendOrganizationAndApp(dirs[i]);
executed 1 time by 1 test: appendOrganizationAndApp(dirs[i]);
Executed by:
  • tst_qstandardpaths
1
322 break;
executed 1 time by 1 test: break;
Executed by:
  • tst_qstandardpaths
1
323 case GenericDataLocation:
executed 144 times by 4 tests: case GenericDataLocation:
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qmimetype
  • tst_qstandardpaths
144
324 dirs = xdgDataDirs();-
325 break;
executed 144 times by 4 tests: break;
Executed by:
  • tst_QDebug
  • tst_QMimeDatabase
  • tst_qmimetype
  • tst_qstandardpaths
144
326 case ApplicationsLocation:
executed 4 times by 1 test: case ApplicationsLocation:
Executed by:
  • tst_qstandardpaths
4
327 dirs = xdgDataDirs();-
328 for (int i = 0; i < dirs.count(); ++i)
i < dirs.count()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qstandardpaths
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qstandardpaths
4-6
329 dirs[i].append(QLatin1String("/applications"));
executed 6 times by 1 test: dirs[i].append(QLatin1String("/applications"));
Executed by:
  • tst_qstandardpaths
6
330 break;
executed 4 times by 1 test: break;
Executed by:
  • tst_qstandardpaths
4
331 case AppDataLocation:
executed 1 time by 1 test: case AppDataLocation:
Executed by:
  • tst_qstandardpaths
1
332 case AppLocalDataLocation:
executed 3 times by 1 test: case AppLocalDataLocation:
Executed by:
  • tst_qstandardpaths
3
333 dirs = xdgDataDirs();-
334 for (int i = 0; i < dirs.count(); ++i)
i < dirs.count()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qstandardpaths
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qstandardpaths
4-8
335 appendOrganizationAndApp(dirs[i]);
executed 8 times by 1 test: appendOrganizationAndApp(dirs[i]);
Executed by:
  • tst_qstandardpaths
8
336 break;
executed 4 times by 1 test: break;
Executed by:
  • tst_qstandardpaths
4
337 default:
executed 27 times by 2 tests: default:
Executed by:
  • tst_QFileSystemModel
  • tst_qstandardpaths
27
338 break;
executed 27 times by 2 tests: break;
Executed by:
  • tst_QFileSystemModel
  • tst_qstandardpaths
27
339 }-
340 const QString localDir = writableLocation(type);-
341 dirs.prepend(localDir);-
342 return dirs;
executed 1061 times by 28 tests: return dirs;
Executed by:
  • tst_QApplication
  • tst_QCommandLineParser
  • tst_QCoreApplication
  • tst_QDBusConnectionNoBus
  • tst_QDBusConnectionNoLibDBus1
  • tst_QDBusConnection_Delayed
  • tst_QDebug
  • tst_QDnsLookup_Appless
  • tst_QFileSystemModel
  • tst_QGlobal
  • tst_QGuiApplication
  • tst_QLoggingRegistry
  • tst_QMimeDatabase
  • tst_QNetworkConfigurationManager
  • tst_QSql
  • tst_qapplication - unknown status
  • tst_qdbusabstractadaptor - unknown status
  • tst_qdbusabstractinterface - unknown status
  • tst_qdbusinterface - unknown status
  • tst_qdbusmarshall - unknown status
  • tst_qlogging - unknown status
  • tst_qmimetype
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsharedmemory - unknown status
  • ...
1061
343}-
344-
345QT_END_NAMESPACE-
346-
347#endif // QT_NO_STANDARDPATHS-
Source codeSwitch to Preprocessed file

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