| Line | Source Code | Coverage |
|---|
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | static void appendOrganizationAndApp(QString &path) | - |
| 11 | { | - |
| 12 | | - |
| 13 | const QString org = QCoreApplication::organizationName(); | - |
| 14 | if (!org.isEmpty()) evaluated: !org.isEmpty()| yes Evaluation Count:8 | yes Evaluation Count:7 |
| 7-8 |
| 15 | path += QLatin1Char('/') + org; executed: path += QLatin1Char('/') + org;Execution Count:8 | 8 |
| 16 | const QString appName = QCoreApplication::applicationName(); | - |
| 17 | if (!appName.isEmpty()) partially evaluated: !appName.isEmpty()| yes Evaluation Count:15 | no Evaluation Count:0 |
| 0-15 |
| 18 | path += QLatin1Char('/') + appName; executed: path += QLatin1Char('/') + appName;Execution Count:15 | 15 |
| 19 | | - |
| 20 | | - |
| 21 | | - |
| 22 | } executed: }Execution Count:15 | 15 |
| 23 | | - |
| 24 | QString QStandardPaths::writableLocation(StandardLocation type) | - |
| 25 | { | - |
| 26 | switch (type) { | - |
| 27 | case HomeLocation: | - |
| 28 | return QDir::homePath(); executed: return QDir::homePath();Execution Count:2 | 2 |
| 29 | case TempLocation: | - |
| 30 | return QDir::tempPath(); executed: return QDir::tempPath();Execution Count:2 | 2 |
| 31 | case CacheLocation: | - |
| 32 | case GenericCacheLocation: | - |
| 33 | { | - |
| 34 | | - |
| 35 | QString xdgCacheHome = QFile::decodeName(qgetenv("XDG_CACHE_HOME")); | - |
| 36 | if (isTestModeEnabled()) evaluated: isTestModeEnabled()| yes Evaluation Count:4 | yes Evaluation Count:4 |
| 4 |
| 37 | xdgCacheHome = QDir::homePath() + QLatin1String("/.qttest/cache"); executed: xdgCacheHome = QDir::homePath() + QLatin1String("/.qttest/cache");Execution Count:4 | 4 |
| 38 | if (xdgCacheHome.isEmpty()) evaluated: xdgCacheHome.isEmpty()| yes Evaluation Count:4 | yes Evaluation Count:4 |
| 4 |
| 39 | xdgCacheHome = QDir::homePath() + QLatin1String("/.cache"); executed: xdgCacheHome = QDir::homePath() + QLatin1String("/.cache");Execution Count:4 | 4 |
| 40 | if (type == QStandardPaths::CacheLocation) evaluated: type == QStandardPaths::CacheLocation| yes Evaluation Count:3 | yes Evaluation Count:5 |
| 3-5 |
| 41 | appendOrganizationAndApp(xdgCacheHome); executed: appendOrganizationAndApp(xdgCacheHome);Execution Count:3 | 3 |
| 42 | return xdgCacheHome; executed: return xdgCacheHome;Execution Count:8 | 8 |
| 43 | } | - |
| 44 | case DataLocation: | - |
| 45 | case GenericDataLocation: | - |
| 46 | { | - |
| 47 | QString xdgDataHome = QFile::decodeName(qgetenv("XDG_DATA_HOME")); | - |
| 48 | if (isTestModeEnabled()) evaluated: isTestModeEnabled()| yes Evaluation Count:4 | yes Evaluation Count:81 |
| 4-81 |
| 49 | xdgDataHome = QDir::homePath() + QLatin1String("/.qttest/share"); executed: xdgDataHome = QDir::homePath() + QLatin1String("/.qttest/share");Execution Count:4 | 4 |
| 50 | if (xdgDataHome.isEmpty()) evaluated: xdgDataHome.isEmpty()| yes Evaluation Count:13 | yes Evaluation Count:72 |
| 13-72 |
| 51 | xdgDataHome = QDir::homePath() + QLatin1String("/.local/share"); executed: xdgDataHome = QDir::homePath() + QLatin1String("/.local/share");Execution Count:13 | 13 |
| 52 | if (type == QStandardPaths::DataLocation) evaluated: type == QStandardPaths::DataLocation| yes Evaluation Count:10 | yes Evaluation Count:75 |
| 10-75 |
| 53 | appendOrganizationAndApp(xdgDataHome); executed: appendOrganizationAndApp(xdgDataHome);Execution Count:10 | 10 |
| 54 | return xdgDataHome; executed: return xdgDataHome;Execution Count:85 | 85 |
| 55 | } | - |
| 56 | case ConfigLocation: | - |
| 57 | { | - |
| 58 | | - |
| 59 | QString xdgConfigHome = QFile::decodeName(qgetenv("XDG_CONFIG_HOME")); | - |
| 60 | if (isTestModeEnabled()) evaluated: isTestModeEnabled()| yes Evaluation Count:3 | yes Evaluation Count:10 |
| 3-10 |
| 61 | xdgConfigHome = QDir::homePath() + QLatin1String("/.qttest/config"); executed: xdgConfigHome = QDir::homePath() + QLatin1String("/.qttest/config");Execution Count:3 | 3 |
| 62 | if (xdgConfigHome.isEmpty()) evaluated: xdgConfigHome.isEmpty()| yes Evaluation Count:3 | yes Evaluation Count:10 |
| 3-10 |
| 63 | xdgConfigHome = QDir::homePath() + QLatin1String("/.config"); executed: xdgConfigHome = QDir::homePath() + QLatin1String("/.config");Execution Count:3 | 3 |
| 64 | return xdgConfigHome; executed: return xdgConfigHome;Execution Count:13 | 13 |
| 65 | } | - |
| 66 | case RuntimeLocation: | - |
| 67 | { | - |
| 68 | const uid_t myUid = geteuid(); | - |
| 69 | | - |
| 70 | QString xdgRuntimeDir = QFile::decodeName(qgetenv("XDG_RUNTIME_DIR")); | - |
| 71 | if (xdgRuntimeDir.isEmpty()) { evaluated: xdgRuntimeDir.isEmpty()| yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
| 72 | const QString userName = QFileSystemEngine::resolveUserName(myUid); | - |
| 73 | xdgRuntimeDir = QDir::tempPath() + QLatin1String("/runtime-") + userName; | - |
| 74 | QDir dir(xdgRuntimeDir); | - |
| 75 | if (!dir.exists()) { partially evaluated: !dir.exists()| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 76 | if (!QDir().mkdir(xdgRuntimeDir)) { never evaluated: !QDir().mkdir(xdgRuntimeDir) | 0 |
| 77 | QMessageLogger("io/qstandardpaths_unix.cpp", 126, __PRETTY_FUNCTION__).warning("QStandardPaths: error creating runtime directory %s: %s", QString(xdgRuntimeDir).toLocal8Bit().constData(), QString(qt_error_string((*__errno_location ()))).toLocal8Bit().constData()); | - |
| 78 | return QString(); never executed: return QString(); | 0 |
| 79 | } | - |
| 80 | } | 0 |
| 81 | QMessageLogger("io/qstandardpaths_unix.cpp", 130, __PRETTY_FUNCTION__).warning("QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '%s'", QString(xdgRuntimeDir).toLocal8Bit().constData()); | - |
| 82 | } executed: }Execution Count:2 | 2 |
| 83 | | - |
| 84 | QFileInfo fileInfo(xdgRuntimeDir); | - |
| 85 | if (fileInfo.ownerId() != myUid) { evaluated: fileInfo.ownerId() != myUid| yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
| 86 | QMessageLogger("io/qstandardpaths_unix.cpp", 135, __PRETTY_FUNCTION__).warning("QStandardPaths: wrong ownership on runtime directory %s, %d instead of %d", QString(xdgRuntimeDir).toLocal8Bit().constData(), | - |
| 87 | fileInfo.ownerId(), myUid); | - |
| 88 | return QString(); executed: return QString();Execution Count:1 | 1 |
| 89 | } | - |
| 90 | | - |
| 91 | QFile file(xdgRuntimeDir); | - |
| 92 | const QFile::Permissions wantedPerms = QFile::ReadUser | QFile::WriteUser | QFile::ExeUser; | - |
| 93 | if (file.permissions() != wantedPerms && !file.setPermissions(wantedPerms)) { partially evaluated: file.permissions() != wantedPerms| yes Evaluation Count:2 | no Evaluation Count:0 |
partially evaluated: !file.setPermissions(wantedPerms)| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 94 | QMessageLogger("io/qstandardpaths_unix.cpp", 143, __PRETTY_FUNCTION__).warning("QStandardPaths: wrong permissions on runtime directory %s", QString(xdgRuntimeDir).toLocal8Bit().constData()); | - |
| 95 | return QString(); never executed: return QString(); | 0 |
| 96 | } | - |
| 97 | return xdgRuntimeDir; executed: return xdgRuntimeDir;Execution Count:2 | 2 |
| 98 | } | - |
| 99 | default: | - |
| 100 | break; executed: break;Execution Count:17 | 17 |
| 101 | } | - |
| 102 | | - |
| 103 | | - |
| 104 | | - |
| 105 | QString xdgConfigHome = QFile::decodeName(qgetenv("XDG_CONFIG_HOME")); | - |
| 106 | if (xdgConfigHome.isEmpty()) evaluated: xdgConfigHome.isEmpty()| yes Evaluation Count:16 | yes Evaluation Count:1 |
| 1-16 |
| 107 | xdgConfigHome = QDir::homePath() + QLatin1String("/.config"); executed: xdgConfigHome = QDir::homePath() + QLatin1String("/.config");Execution Count:16 | 16 |
| 108 | QFile file(xdgConfigHome + QLatin1String("/user-dirs.dirs")); | - |
| 109 | if (!isTestModeEnabled() && file.open(QIODevice::ReadOnly)) { partially evaluated: !isTestModeEnabled()| yes Evaluation Count:17 | no Evaluation Count:0 |
partially evaluated: file.open(QIODevice::ReadOnly)| no Evaluation Count:0 | yes Evaluation Count:17 |
| 0-17 |
| 110 | QHash<QString, QString> lines; | - |
| 111 | QTextStream stream(&file); | - |
| 112 | | - |
| 113 | QRegExp exp(QLatin1String("^XDG_(.*)_DIR=(.*)$")); | - |
| 114 | while (!stream.atEnd()) { never evaluated: !stream.atEnd() | 0 |
| 115 | const QString &line = stream.readLine(); | - |
| 116 | if (exp.indexIn(line) != -1) { never evaluated: exp.indexIn(line) != -1 | 0 |
| 117 | const QStringList lst = exp.capturedTexts(); | - |
| 118 | const QString key = lst.at(1); | - |
| 119 | QString value = lst.at(2); | - |
| 120 | if (value.length() > 2 never evaluated: value.length() > 2 | 0 |
| 121 | && value.startsWith(QLatin1Char('\"')) never evaluated: value.startsWith(QLatin1Char('\"')) | 0 |
| 122 | && value.endsWith(QLatin1Char('\"'))) never evaluated: value.endsWith(QLatin1Char('\"')) | 0 |
| 123 | value = value.mid(1, value.length() - 2); never executed: value = value.mid(1, value.length() - 2); | 0 |
| 124 | | - |
| 125 | lines[key] = value; | - |
| 126 | } | 0 |
| 127 | } | 0 |
| 128 | | - |
| 129 | QString key; | - |
| 130 | switch (type) { | - |
| 131 | case DesktopLocation: | - |
| 132 | key = QLatin1String("DESKTOP"); | - |
| 133 | break; | 0 |
| 134 | case DocumentsLocation: | - |
| 135 | key = QLatin1String("DOCUMENTS"); | - |
| 136 | break; | 0 |
| 137 | case PicturesLocation: | - |
| 138 | key = QLatin1String("PICTURES"); | - |
| 139 | break; | 0 |
| 140 | case MusicLocation: | - |
| 141 | key = QLatin1String("MUSIC"); | - |
| 142 | break; | 0 |
| 143 | case MoviesLocation: | - |
| 144 | key = QLatin1String("VIDEOS"); | - |
| 145 | break; | 0 |
| 146 | case DownloadLocation: | - |
| 147 | key = QLatin1String("DOWNLOAD"); | - |
| 148 | break; | 0 |
| 149 | default: | - |
| 150 | break; | 0 |
| 151 | } | - |
| 152 | if (!key.isEmpty()) { never evaluated: !key.isEmpty() | 0 |
| 153 | QString value = lines.value(key); | - |
| 154 | if (!value.isEmpty()) { never evaluated: !value.isEmpty() | 0 |
| 155 | | - |
| 156 | if (value.startsWith(QLatin1String("$HOME"))) never evaluated: value.startsWith(QLatin1String("$HOME")) | 0 |
| 157 | value = QDir::homePath() + value.mid(5); never executed: value = QDir::homePath() + value.mid(5); | 0 |
| 158 | return value; never executed: return value; | 0 |
| 159 | } | - |
| 160 | } | 0 |
| 161 | } | 0 |
| 162 | | - |
| 163 | | - |
| 164 | QString path; | - |
| 165 | switch (type) { | - |
| 166 | case DesktopLocation: | - |
| 167 | path = QDir::homePath() + QLatin1String("/Desktop"); | - |
| 168 | break; executed: break;Execution Count:2 | 2 |
| 169 | case DocumentsLocation: | - |
| 170 | path = QDir::homePath() + QLatin1String("/Documents"); | - |
| 171 | break; executed: break;Execution Count:2 | 2 |
| 172 | case PicturesLocation: | - |
| 173 | path = QDir::homePath() + QLatin1String("/Pictures"); | - |
| 174 | break; executed: break;Execution Count:2 | 2 |
| 175 | | - |
| 176 | case FontsLocation: | - |
| 177 | path = QDir::homePath() + QLatin1String("/.fonts"); | - |
| 178 | break; executed: break;Execution Count:2 | 2 |
| 179 | | - |
| 180 | case MusicLocation: | - |
| 181 | path = QDir::homePath() + QLatin1String("/Music"); | - |
| 182 | break; executed: break;Execution Count:2 | 2 |
| 183 | | - |
| 184 | case MoviesLocation: | - |
| 185 | path = QDir::homePath() + QLatin1String("/Videos"); | - |
| 186 | break; executed: break;Execution Count:2 | 2 |
| 187 | case DownloadLocation: | - |
| 188 | path = QDir::homePath() + QLatin1String("/Downloads"); | - |
| 189 | break; executed: break;Execution Count:2 | 2 |
| 190 | case ApplicationsLocation: | - |
| 191 | path = writableLocation(GenericDataLocation) + QLatin1String("/applications"); | - |
| 192 | break; executed: break;Execution Count:3 | 3 |
| 193 | | - |
| 194 | default: | - |
| 195 | break; | 0 |
| 196 | } | - |
| 197 | | - |
| 198 | return path; executed: return path;Execution Count:17 | 17 |
| 199 | } | - |
| 200 | | - |
| 201 | static QStringList xdgDataDirs() | - |
| 202 | { | - |
| 203 | QStringList dirs; | - |
| 204 | | - |
| 205 | QString xdgDataDirsEnv = QFile::decodeName(qgetenv("XDG_DATA_DIRS")); | - |
| 206 | if (xdgDataDirsEnv.isEmpty()) { evaluated: xdgDataDirsEnv.isEmpty()| yes Evaluation Count:2 | yes Evaluation Count:62 |
| 2-62 |
| 207 | dirs.append(QString::fromLatin1("/usr/local/share")); | - |
| 208 | dirs.append(QString::fromLatin1("/usr/share")); | - |
| 209 | } else { executed: }Execution Count:2 | 2 |
| 210 | dirs = xdgDataDirsEnv.split(QLatin1Char(':')); | - |
| 211 | } executed: }Execution Count:62 | 62 |
| 212 | return dirs; executed: return dirs;Execution Count:64 | 64 |
| 213 | } | - |
| 214 | | - |
| 215 | QStringList QStandardPaths::standardLocations(StandardLocation type) | - |
| 216 | { | - |
| 217 | QStringList dirs; | - |
| 218 | switch (type) { | - |
| 219 | case ConfigLocation: | - |
| 220 | { | - |
| 221 | | - |
| 222 | const QString xdgConfigDirs = QFile::decodeName(qgetenv("XDG_CONFIG_DIRS")); | - |
| 223 | if (xdgConfigDirs.isEmpty()) evaluated: xdgConfigDirs.isEmpty()| yes Evaluation Count:1 | yes Evaluation Count:6 |
| 1-6 |
| 224 | dirs.append(QString::fromLatin1("/etc/xdg")); executed: dirs.append(QString::fromLatin1("/etc/xdg"));Execution Count:1 | 1 |
| 225 | else | - |
| 226 | dirs = xdgConfigDirs.split(QLatin1Char(':')); executed: dirs = xdgConfigDirs.split(QLatin1Char(':'));Execution Count:6 | 6 |
| 227 | } | - |
| 228 | break; executed: break;Execution Count:7 | 7 |
| 229 | case GenericDataLocation: | - |
| 230 | dirs = xdgDataDirs(); | - |
| 231 | break; executed: break;Execution Count:62 | 62 |
| 232 | case ApplicationsLocation: | - |
| 233 | dirs = xdgDataDirs(); | - |
| 234 | for (int i = 0; i < dirs.count(); ++i) evaluated: i < dirs.count()| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
| 235 | dirs[i].append(QLatin1String("/applications")); executed: dirs[i].append(QLatin1String("/applications"));Execution Count:1 | 1 |
| 236 | break; executed: break;Execution Count:1 | 1 |
| 237 | case DataLocation: | - |
| 238 | dirs = xdgDataDirs(); | - |
| 239 | for (int i = 0; i < dirs.count(); ++i) evaluated: i < dirs.count()| yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
| 240 | appendOrganizationAndApp(dirs[i]); executed: appendOrganizationAndApp(dirs[i]);Execution Count:2 | 2 |
| 241 | break; executed: break;Execution Count:1 | 1 |
| 242 | default: | - |
| 243 | break; executed: break;Execution Count:1 | 1 |
| 244 | } | - |
| 245 | const QString localDir = writableLocation(type); | - |
| 246 | dirs.prepend(localDir); | - |
| 247 | return dirs; executed: return dirs;Execution Count:72 | 72 |
| 248 | } | - |
| 249 | | - |
| 250 | | - |
| 251 | | - |
| | |