| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/io/qstandardpaths.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 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 | - | |||||||||||||
| 36 | #include <qdir.h> | - | ||||||||||||
| 37 | #include <qfileinfo.h> | - | ||||||||||||
| 38 | - | |||||||||||||
| 39 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||
| 40 | #include <qobject.h> | - | ||||||||||||
| 41 | #include <qcoreapplication.h> | - | ||||||||||||
| 42 | #endif | - | ||||||||||||
| 43 | - | |||||||||||||
| 44 | #ifndef QT_NO_STANDARDPATHS | - | ||||||||||||
| 45 | - | |||||||||||||
| 46 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 47 | - | |||||||||||||
| 48 | /*! | - | ||||||||||||
| 49 | \class QStandardPaths | - | ||||||||||||
| 50 | \inmodule QtCore | - | ||||||||||||
| 51 | \brief The QStandardPaths class provides methods for accessing standard paths. | - | ||||||||||||
| 52 | \since 5.0 | - | ||||||||||||
| 53 | - | |||||||||||||
| 54 | This class contains functions to query standard locations on the local | - | ||||||||||||
| 55 | filesystem, for common tasks such as user-specific directories or system-wide | - | ||||||||||||
| 56 | configuration directories. | - | ||||||||||||
| 57 | */ | - | ||||||||||||
| 58 | - | |||||||||||||
| 59 | /*! | - | ||||||||||||
| 60 | \enum QStandardPaths::StandardLocation | - | ||||||||||||
| 61 | - | |||||||||||||
| 62 | This enum describes the different locations that can be queried using | - | ||||||||||||
| 63 | methods such as QStandardPaths::writableLocation, QStandardPaths::standardLocations, | - | ||||||||||||
| 64 | and QStandardPaths::displayName. | - | ||||||||||||
| 65 | - | |||||||||||||
| 66 | Some of the values in this enum represent a user configuration. Such enum | - | ||||||||||||
| 67 | values will return the same paths in different applications, so they could | - | ||||||||||||
| 68 | be used to share data with other applications. Other values are specific to | - | ||||||||||||
| 69 | this application. Each enum value in the table below describes whether it's | - | ||||||||||||
| 70 | application-specific or generic. | - | ||||||||||||
| 71 | - | |||||||||||||
| 72 | Application-specific directories should be assumed to be unreachable by | - | ||||||||||||
| 73 | other applications. Therefore, files placed there might not be readable by | - | ||||||||||||
| 74 | other applications, even if run by the same user. On the other hand, generic | - | ||||||||||||
| 75 | directories should be assumed to be accessible by all applications run by | - | ||||||||||||
| 76 | this user, but should still be assumed to be unreachable by applications by | - | ||||||||||||
| 77 | other users. | - | ||||||||||||
| 78 | - | |||||||||||||
| 79 | Data interchange with other users is out of the scope of QStandardPaths. | - | ||||||||||||
| 80 | - | |||||||||||||
| 81 | \value DesktopLocation Returns the user's desktop directory. This is a generic value. | - | ||||||||||||
| 82 | On systems with no concept of a desktop. | - | ||||||||||||
| 83 | \value DocumentsLocation Returns the directory containing user document files. | - | ||||||||||||
| 84 | This is a generic value. The returned path is never empty. | - | ||||||||||||
| 85 | \value FontsLocation Returns the directory containing user's fonts. This is a generic value. | - | ||||||||||||
| 86 | Note that installing fonts may require additional, platform-specific operations. | - | ||||||||||||
| 87 | \value ApplicationsLocation Returns the directory containing the user applications | - | ||||||||||||
| 88 | (either executables, application bundles, or shortcuts to them). This is a generic value. | - | ||||||||||||
| 89 | Note that installing applications may require additional, platform-specific operations. | - | ||||||||||||
| 90 | Files, folders or shortcuts in this directory are platform-specific. | - | ||||||||||||
| 91 | \value MusicLocation Returns the directory containing the user's music or other audio files. | - | ||||||||||||
| 92 | This is a generic value. If no directory specific for music files exists, a sensible | - | ||||||||||||
| 93 | fallback for storing user documents is returned. | - | ||||||||||||
| 94 | \value MoviesLocation Returns the directory containing the user's movies and videos. | - | ||||||||||||
| 95 | This is a generic value. If no directory specific for movie files exists, a sensible | - | ||||||||||||
| 96 | fallback for storing user documents is returned. | - | ||||||||||||
| 97 | \value PicturesLocation Returns the directory containing the user's pictures or photos. | - | ||||||||||||
| 98 | This is a generic value. If no directory specific for picture files exists, a sensible | - | ||||||||||||
| 99 | fallback for storing user documents is returned. | - | ||||||||||||
| 100 | \value TempLocation Returns a directory where temporary files can be stored. The returned value | - | ||||||||||||
| 101 | might be application-specific, shared among other applications for this user, or even | - | ||||||||||||
| 102 | system-wide. The returned path is never empty. | - | ||||||||||||
| 103 | \value HomeLocation Returns the user's home directory (the same as QDir::homePath()). On Unix | - | ||||||||||||
| 104 | systems, this is equal to the HOME environment variable. This value might be | - | ||||||||||||
| 105 | generic or application-specific, but the returned path is never empty. | - | ||||||||||||
| 106 | \value DataLocation Returns the same value as AppLocalDataLocation. This enumeration value | - | ||||||||||||
| 107 | is deprecated. Using AppDataLocation is preferable since on Windows, the roaming path is | - | ||||||||||||
| 108 | recommended. | - | ||||||||||||
| 109 | \value CacheLocation Returns a directory location where user-specific | - | ||||||||||||
| 110 | non-essential (cached) data should be written. This is an application-specific directory. | - | ||||||||||||
| 111 | The returned path is never empty. | - | ||||||||||||
| 112 | \value GenericCacheLocation Returns a directory location where user-specific non-essential | - | ||||||||||||
| 113 | (cached) data, shared across applications, should be written. This is a generic value. | - | ||||||||||||
| 114 | Note that the returned path may be empty if the system has no concept of shared cache. | - | ||||||||||||
| 115 | \value GenericDataLocation Returns a directory location where persistent | - | ||||||||||||
| 116 | data shared across applications can be stored. This is a generic value. The returned | - | ||||||||||||
| 117 | path is never empty. | - | ||||||||||||
| 118 | \value RuntimeLocation Returns a directory location where runtime communication | - | ||||||||||||
| 119 | files should be written, like Unix local sockets. This is a generic value. | - | ||||||||||||
| 120 | The returned path may be empty on some systems. | - | ||||||||||||
| 121 | \value ConfigLocation Returns a directory location where user-specific | - | ||||||||||||
| 122 | configuration files should be written. This may be either a generic value | - | ||||||||||||
| 123 | or application-specific, and the returned path is never empty. | - | ||||||||||||
| 124 | \value DownloadLocation Returns a directory for user's downloaded files. This is a generic value. | - | ||||||||||||
| 125 | If no directory specific for downloads exists, a sensible fallback for storing user | - | ||||||||||||
| 126 | documents is returned. | - | ||||||||||||
| 127 | \value GenericConfigLocation Returns a directory location where user-specific | - | ||||||||||||
| 128 | configuration files shared between multiple applications should be written. | - | ||||||||||||
| 129 | This is a generic value and the returned path is never empty. | - | ||||||||||||
| 130 | \value AppDataLocation Returns a directory location where persistent | - | ||||||||||||
| 131 | application data can be stored. This is an application-specific directory. | - | ||||||||||||
| 132 | To obtain a path to store data to be shared with other applications, use | - | ||||||||||||
| 133 | QStandardPaths::GenericDataLocation. The returned path is never empty. | - | ||||||||||||
| 134 | On the Windows operating system, this returns the roaming path. | - | ||||||||||||
| 135 | This enum value was added in Qt 5.4. | - | ||||||||||||
| 136 | \value AppLocalDataLocation Returns the local settings path on the Windows operating | - | ||||||||||||
| 137 | system. On all other platforms, it returns the same value as AppDataLocation. | - | ||||||||||||
| 138 | This enum value was added in Qt 5.4. | - | ||||||||||||
| 139 | \value AppConfigLocation Returns a directory location where user-specific | - | ||||||||||||
| 140 | configuration files should be written. This is an application-specific directory, | - | ||||||||||||
| 141 | and the returned path is never empty. | - | ||||||||||||
| 142 | This enum value was added in Qt 5.5. | - | ||||||||||||
| 143 | - | |||||||||||||
| 144 | The following table gives examples of paths on different operating systems. | - | ||||||||||||
| 145 | The first path is the writable path (unless noted). Other, additional | - | ||||||||||||
| 146 | paths, if any, represent non-writable locations. | - | ||||||||||||
| 147 | - | |||||||||||||
| 148 | \table | - | ||||||||||||
| 149 | \header \li Path type \li \macos \li Windows | - | ||||||||||||
| 150 | \row \li DesktopLocation | - | ||||||||||||
| 151 | \li "~/Desktop" | - | ||||||||||||
| 152 | \li "C:/Users/<USER>/Desktop" | - | ||||||||||||
| 153 | \row \li DocumentsLocation | - | ||||||||||||
| 154 | \li "~/Documents" | - | ||||||||||||
| 155 | \li "C:/Users/<USER>/Documents" | - | ||||||||||||
| 156 | \row \li FontsLocation | - | ||||||||||||
| 157 | \li "/System/Library/Fonts" (not writable) | - | ||||||||||||
| 158 | \li "C:/Windows/Fonts" (not writable) | - | ||||||||||||
| 159 | \row \li ApplicationsLocation | - | ||||||||||||
| 160 | \li "/Applications" (not writable) | - | ||||||||||||
| 161 | \li "C:/Users/<USER>/AppData/Roaming/Microsoft/Windows/Start Menu/Programs" | - | ||||||||||||
| 162 | \row \li MusicLocation | - | ||||||||||||
| 163 | \li "~/Music" | - | ||||||||||||
| 164 | \li "C:/Users/<USER>/Music" | - | ||||||||||||
| 165 | \row \li MoviesLocation | - | ||||||||||||
| 166 | \li "~/Movies" | - | ||||||||||||
| 167 | \li "C:/Users/<USER>/Videos" | - | ||||||||||||
| 168 | \row \li PicturesLocation | - | ||||||||||||
| 169 | \li "~/Pictures" | - | ||||||||||||
| 170 | \li "C:/Users/<USER>/Pictures" | - | ||||||||||||
| 171 | \row \li TempLocation | - | ||||||||||||
| 172 | \li randomly generated by the OS | - | ||||||||||||
| 173 | \li "C:/Users/<USER>/AppData/Local/Temp" | - | ||||||||||||
| 174 | \row \li HomeLocation | - | ||||||||||||
| 175 | \li "~" | - | ||||||||||||
| 176 | \li "C:/Users/<USER>" | - | ||||||||||||
| 177 | \row \li DataLocation | - | ||||||||||||
| 178 | \li "~/Library/Application Support/<APPNAME>", "/Library/Application Support/<APPNAME>". "<APPDIR>/../Resources" | - | ||||||||||||
| 179 | \li "C:/Users/<USER>/AppData/Local/<APPNAME>", "C:/ProgramData/<APPNAME>", "<APPDIR>", "<APPDIR>/data" | - | ||||||||||||
| 180 | \row \li CacheLocation | - | ||||||||||||
| 181 | \li "~/Library/Caches/<APPNAME>", "/Library/Caches/<APPNAME>" | - | ||||||||||||
| 182 | \li "C:/Users/<USER>/AppData/Local/<APPNAME>/cache" | - | ||||||||||||
| 183 | \row \li GenericDataLocation | - | ||||||||||||
| 184 | \li "~/Library/Application Support", "/Library/Application Support" | - | ||||||||||||
| 185 | \li "C:/Users/<USER>/AppData/Local", "C:/ProgramData", "<APPDIR>", "<APPDIR>/data" | - | ||||||||||||
| 186 | \row \li RuntimeLocation | - | ||||||||||||
| 187 | \li "~/Library/Application Support" | - | ||||||||||||
| 188 | \li "C:/Users/<USER>" | - | ||||||||||||
| 189 | \row \li ConfigLocation | - | ||||||||||||
| 190 | \li "~/Library/Preferences" | - | ||||||||||||
| 191 | \li "C:/Users/<USER>/AppData/Local/<APPNAME>", "C:/ProgramData/<APPNAME>" | - | ||||||||||||
| 192 | \row \li GenericConfigLocation | - | ||||||||||||
| 193 | \li "~/Library/Preferences" | - | ||||||||||||
| 194 | \li "C:/Users/<USER>/AppData/Local", "C:/ProgramData" | - | ||||||||||||
| 195 | \row \li DownloadLocation | - | ||||||||||||
| 196 | \li "~/Downloads" | - | ||||||||||||
| 197 | \li "C:/Users/<USER>/Documents" | - | ||||||||||||
| 198 | \row \li GenericCacheLocation | - | ||||||||||||
| 199 | \li "~/Library/Caches", "/Library/Caches" | - | ||||||||||||
| 200 | \li "C:/Users/<USER>/AppData/Local/cache" | - | ||||||||||||
| 201 | \row \li AppDataLocation | - | ||||||||||||
| 202 | \li "~/Library/Application Support/<APPNAME>", "/Library/Application Support/<APPNAME>". "<APPDIR>/../Resources" | - | ||||||||||||
| 203 | \li "C:/Users/<USER>/AppData/Roaming/<APPNAME>", "C:/ProgramData/<APPNAME>", "<APPDIR>", "<APPDIR>/data" | - | ||||||||||||
| 204 | \row \li AppLocalDataLocation | - | ||||||||||||
| 205 | \li "~/Library/Application Support/<APPNAME>", "/Library/Application Support/<APPNAME>". "<APPDIR>/../Resources" | - | ||||||||||||
| 206 | \li "C:/Users/<USER>/AppData/Local/<APPNAME>", "C:/ProgramData/<APPNAME>", "<APPDIR>", "<APPDIR>/data" | - | ||||||||||||
| 207 | \row \li AppConfigLocation | - | ||||||||||||
| 208 | \li "~/Library/Preferences/<APPNAME>" | - | ||||||||||||
| 209 | \li "C:/Users/<USER>/AppData/Local/<APPNAME>", "C:/ProgramData/<APPNAME>" | - | ||||||||||||
| 210 | \endtable | - | ||||||||||||
| 211 | - | |||||||||||||
| 212 | \table | - | ||||||||||||
| 213 | \header \li Path type \li Blackberry \li Linux | - | ||||||||||||
| 214 | \row \li DesktopLocation | - | ||||||||||||
| 215 | \li "<APPROOT>/data" | - | ||||||||||||
| 216 | \li "~/Desktop" | - | ||||||||||||
| 217 | \row \li DocumentsLocation | - | ||||||||||||
| 218 | \li "<APPROOT>/shared/documents" | - | ||||||||||||
| 219 | \li "~/Documents" | - | ||||||||||||
| 220 | \row \li FontsLocation | - | ||||||||||||
| 221 | \li "/base/usr/fonts" (not writable) | - | ||||||||||||
| 222 | \li "~/.fonts" | - | ||||||||||||
| 223 | \row \li ApplicationsLocation | - | ||||||||||||
| 224 | \li not supported (directory not readable) | - | ||||||||||||
| 225 | \li "~/.local/share/applications", "/usr/local/share/applications", "/usr/share/applications" | - | ||||||||||||
| 226 | \row \li MusicLocation | - | ||||||||||||
| 227 | \li "<APPROOT>/shared/music" | - | ||||||||||||
| 228 | \li "~/Music" | - | ||||||||||||
| 229 | \row \li MoviesLocation | - | ||||||||||||
| 230 | \li "<APPROOT>/shared/videos" | - | ||||||||||||
| 231 | \li "~/Videos" | - | ||||||||||||
| 232 | \row \li PicturesLocation | - | ||||||||||||
| 233 | \li "<APPROOT>/shared/photos" | - | ||||||||||||
| 234 | \li "~/Pictures" | - | ||||||||||||
| 235 | \row \li TempLocation | - | ||||||||||||
| 236 | \li "/var/tmp" | - | ||||||||||||
| 237 | \li "/tmp" | - | ||||||||||||
| 238 | \row \li HomeLocation | - | ||||||||||||
| 239 | \li "<APPROOT>/data" | - | ||||||||||||
| 240 | \li "~" | - | ||||||||||||
| 241 | \row \li DataLocation | - | ||||||||||||
| 242 | \li "<APPROOT>/data", "<APPROOT>/app/native/assets" | - | ||||||||||||
| 243 | \li "~/.local/share/<APPNAME>", "/usr/local/share/<APPNAME>", "/usr/share/<APPNAME>" | - | ||||||||||||
| 244 | \row \li CacheLocation | - | ||||||||||||
| 245 | \li "<APPROOT>/data/Cache" | - | ||||||||||||
| 246 | \li "~/.cache/<APPNAME>" | - | ||||||||||||
| 247 | \row \li GenericDataLocation | - | ||||||||||||
| 248 | \li "<APPROOT>/shared/misc" | - | ||||||||||||
| 249 | \li "~/.local/share", "/usr/local/share", "/usr/share" | - | ||||||||||||
| 250 | \row \li RuntimeLocation | - | ||||||||||||
| 251 | \li "/var/tmp" | - | ||||||||||||
| 252 | \li "/run/user/<USER>" | - | ||||||||||||
| 253 | \row \li ConfigLocation | - | ||||||||||||
| 254 | \li "<APPROOT>/data/Settings" | - | ||||||||||||
| 255 | \li "~/.config", "/etc/xdg" | - | ||||||||||||
| 256 | \row \li GenericConfigLocation | - | ||||||||||||
| 257 | \li "<APPROOT>/data/Settings" | - | ||||||||||||
| 258 | \li "~/.config", "/etc/xdg" | - | ||||||||||||
| 259 | \row \li DownloadLocation | - | ||||||||||||
| 260 | \li "<APPROOT>/shared/downloads" | - | ||||||||||||
| 261 | \li "~/Downloads" | - | ||||||||||||
| 262 | \row \li GenericCacheLocation | - | ||||||||||||
| 263 | \li "<APPROOT>/data/Cache" (there is no shared cache) | - | ||||||||||||
| 264 | \li "~/.cache" | - | ||||||||||||
| 265 | \row \li AppDataLocation | - | ||||||||||||
| 266 | \li "<APPROOT>/data", "<APPROOT>/app/native/assets" | - | ||||||||||||
| 267 | \li "~/.local/share/<APPNAME>", "/usr/local/share/<APPNAME>", "/usr/share/<APPNAME>" | - | ||||||||||||
| 268 | \row \li AppLocalDataLocation | - | ||||||||||||
| 269 | \li "<APPROOT>/data", "<APPROOT>/app/native/assets" | - | ||||||||||||
| 270 | \li "~/.local/share/<APPNAME>", "/usr/local/share/<APPNAME>", "/usr/share/<APPNAME>" | - | ||||||||||||
| 271 | \row \li AppConfigLocation | - | ||||||||||||
| 272 | \li "<APPROOT>/data/Settings" | - | ||||||||||||
| 273 | \li "~/.config/<APPNAME>", "/etc/xdg/<APPNAME>" | - | ||||||||||||
| 274 | \endtable | - | ||||||||||||
| 275 | - | |||||||||||||
| 276 | \table | - | ||||||||||||
| 277 | \header \li Path type \li Android \li iOS | - | ||||||||||||
| 278 | \row \li DesktopLocation | - | ||||||||||||
| 279 | \li "<APPROOT>/files" | - | ||||||||||||
| 280 | \li "<APPROOT>/<APPDIR>" (not writable) | - | ||||||||||||
| 281 | \row \li DocumentsLocation | - | ||||||||||||
| 282 | \li "<USER>/Documents", "<USER>/<APPNAME>/Documents" | - | ||||||||||||
| 283 | \li "<APPROOT>/Documents" | - | ||||||||||||
| 284 | \row \li FontsLocation | - | ||||||||||||
| 285 | \li "/system/fonts" (not writable) | - | ||||||||||||
| 286 | \li "<APPROOT>/Documents/.fonts" | - | ||||||||||||
| 287 | \row \li ApplicationsLocation | - | ||||||||||||
| 288 | \li not supported (directory not readable) | - | ||||||||||||
| 289 | \li not supported | - | ||||||||||||
| 290 | \row \li MusicLocation | - | ||||||||||||
| 291 | \li "<USER>/Music", "<USER>/<APPNAME>/Music" | - | ||||||||||||
| 292 | \li "<APPROOT>/Documents/Music" | - | ||||||||||||
| 293 | \row \li MoviesLocation | - | ||||||||||||
| 294 | \li "<USER>/Movies", "<USER>/<APPNAME>/Movies" | - | ||||||||||||
| 295 | \li "<APPROOT>/Documents/Movies" | - | ||||||||||||
| 296 | \row \li PicturesLocation | - | ||||||||||||
| 297 | \li "<USER>/Pictures", "<USER>/<APPNAME>/Pictures" | - | ||||||||||||
| 298 | \li "<APPROOT>/Documents/Pictures", "assets-library://" | - | ||||||||||||
| 299 | \row \li TempLocation | - | ||||||||||||
| 300 | \li "<APPROOT>/cache" | - | ||||||||||||
| 301 | \li "<APPROOT>/tmp" | - | ||||||||||||
| 302 | \row \li HomeLocation | - | ||||||||||||
| 303 | \li "<APPROOT>/files" | - | ||||||||||||
| 304 | \li "<APPROOT>/<APPDIR>" (not writable) | - | ||||||||||||
| 305 | \row \li DataLocation | - | ||||||||||||
| 306 | \li "<APPROOT>/files", "<USER>/<APPNAME>/files" | - | ||||||||||||
| 307 | \li "<APPROOT>/Library/Application Support" | - | ||||||||||||
| 308 | \row \li CacheLocation | - | ||||||||||||
| 309 | \li "<APPROOT>/cache", "<USER>/<APPNAME>/cache" | - | ||||||||||||
| 310 | \li "<APPROOT>/Library/Caches" | - | ||||||||||||
| 311 | \row \li GenericDataLocation | - | ||||||||||||
| 312 | \li "<USER>" | - | ||||||||||||
| 313 | \li "<APPROOT>/Documents" | - | ||||||||||||
| 314 | \row \li RuntimeLocation | - | ||||||||||||
| 315 | \li "<APPROOT>/cache" | - | ||||||||||||
| 316 | \li not supported | - | ||||||||||||
| 317 | \row \li ConfigLocation | - | ||||||||||||
| 318 | \li "<APPROOT>/files/settings" | - | ||||||||||||
| 319 | \li "<APPROOT>/Documents" | - | ||||||||||||
| 320 | \row \li GenericConfigLocation | - | ||||||||||||
| 321 | \li "<APPROOT>/files/settings" (there is no shared settings) | - | ||||||||||||
| 322 | \li "<APPROOT>/Documents" | - | ||||||||||||
| 323 | \row \li DownloadLocation | - | ||||||||||||
| 324 | \li "<USER>/Downloads", "<USER>/<APPNAME>/Downloads" | - | ||||||||||||
| 325 | \li "<APPROOT>/Documents/Download" | - | ||||||||||||
| 326 | \row \li GenericCacheLocation | - | ||||||||||||
| 327 | \li "<APPROOT>/cache" (there is no shared cache) | - | ||||||||||||
| 328 | \li "<APPROOT>/Library/Caches" | - | ||||||||||||
| 329 | \row \li AppDataLocation | - | ||||||||||||
| 330 | \li "<APPROOT>/files", "<USER>/<APPNAME>/files" | - | ||||||||||||
| 331 | \li "<APPROOT>/Library/Application Support" | - | ||||||||||||
| 332 | \row \li AppConfigLocation | - | ||||||||||||
| 333 | \li "<APPROOT>/files/settings" | - | ||||||||||||
| 334 | \li "<APPROOT>/Documents" | - | ||||||||||||
| 335 | \row \li AppLocalDataLocation | - | ||||||||||||
| 336 | \li "<APPROOT>/files", "<USER>/<APPNAME>/files" | - | ||||||||||||
| 337 | \li "<APPROOT>/Library/Application Support" | - | ||||||||||||
| 338 | \endtable | - | ||||||||||||
| 339 | - | |||||||||||||
| 340 | In the table above, \c <APPNAME> is usually the organization name, the | - | ||||||||||||
| 341 | application name, or both, or a unique name generated at packaging. | - | ||||||||||||
| 342 | Similarly, <APPROOT> is the location where this application is installed | - | ||||||||||||
| 343 | (often a sandbox). <APPDIR> is the directory containing the application | - | ||||||||||||
| 344 | executable. | - | ||||||||||||
| 345 | - | |||||||||||||
| 346 | The paths above should not be relied upon, as they may change according to | - | ||||||||||||
| 347 | OS configuration, locale, or they may change in future Qt versions. | - | ||||||||||||
| 348 | - | |||||||||||||
| 349 | \note On Android, applications with open files on the external storage (<USER> locations), | - | ||||||||||||
| 350 | will be killed if the external storage is unmounted. | - | ||||||||||||
| 351 | - | |||||||||||||
| 352 | \note On iOS, if you do pass \c {QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).last()} | - | ||||||||||||
| 353 | as argument to \l{QFileDialog::setDirectory()}, | - | ||||||||||||
| 354 | a native image picker dialog will be used for accessing the user's photo album. | - | ||||||||||||
| 355 | The filename returned can be loaded using QFile and related APIs. | - | ||||||||||||
| 356 | This feature was added in Qt 5.5. | - | ||||||||||||
| 357 | - | |||||||||||||
| 358 | \sa writableLocation(), standardLocations(), displayName(), locate(), locateAll() | - | ||||||||||||
| 359 | */ | - | ||||||||||||
| 360 | - | |||||||||||||
| 361 | /*! | - | ||||||||||||
| 362 | \fn QString QStandardPaths::writableLocation(StandardLocation type) | - | ||||||||||||
| 363 | - | |||||||||||||
| 364 | Returns the directory where files of \a type should be written to, or an empty string | - | ||||||||||||
| 365 | if the location cannot be determined. | - | ||||||||||||
| 366 | - | |||||||||||||
| 367 | \note The storage location returned can be a directory that does not exist; i.e., it | - | ||||||||||||
| 368 | may need to be created by the system or the user. | - | ||||||||||||
| 369 | */ | - | ||||||||||||
| 370 | - | |||||||||||||
| 371 | - | |||||||||||||
| 372 | /*! | - | ||||||||||||
| 373 | \fn QStringList QStandardPaths::standardLocations(StandardLocation type) | - | ||||||||||||
| 374 | - | |||||||||||||
| 375 | Returns all the directories where files of \a type belong. | - | ||||||||||||
| 376 | - | |||||||||||||
| 377 | The list of directories is sorted from high to low priority, starting with | - | ||||||||||||
| 378 | writableLocation() if it can be determined. This list is empty if no locations | - | ||||||||||||
| 379 | for \a type are defined. | - | ||||||||||||
| 380 | - | |||||||||||||
| 381 | \sa writableLocation() | - | ||||||||||||
| 382 | */ | - | ||||||||||||
| 383 | - | |||||||||||||
| 384 | /*! | - | ||||||||||||
| 385 | \enum QStandardPaths::LocateOption | - | ||||||||||||
| 386 | - | |||||||||||||
| 387 | This enum describes the different flags that can be used for | - | ||||||||||||
| 388 | controlling the behavior of QStandardPaths::locate and | - | ||||||||||||
| 389 | QStandardPaths::locateAll. | - | ||||||||||||
| 390 | - | |||||||||||||
| 391 | \value LocateFile return only files | - | ||||||||||||
| 392 | \value LocateDirectory return only directories | - | ||||||||||||
| 393 | */ | - | ||||||||||||
| 394 | - | |||||||||||||
| 395 | static bool existsAsSpecified(const QString &path, QStandardPaths::LocateOptions options) | - | ||||||||||||
| 396 | { | - | ||||||||||||
| 397 | if (options & QStandardPaths::LocateDirectory)
| 119-1907 | ||||||||||||
| 398 | return QDir(path).exists(); executed 119 times by 2 tests: return QDir(path).exists();Executed by:
| 119 | ||||||||||||
| 399 | return QFileInfo(path).isFile(); executed 1907 times by 27 tests: return QFileInfo(path).isFile();Executed by:
| 1907 | ||||||||||||
| 400 | } | - | ||||||||||||
| 401 | - | |||||||||||||
| 402 | /*! | - | ||||||||||||
| 403 | Tries to find a file or directory called \a fileName in the standard locations | - | ||||||||||||
| 404 | for \a type. | - | ||||||||||||
| 405 | - | |||||||||||||
| 406 | The full path to the first file or directory (depending on \a options) found is returned. | - | ||||||||||||
| 407 | If no such file or directory can be found, an empty string is returned. | - | ||||||||||||
| 408 | */ | - | ||||||||||||
| 409 | QString QStandardPaths::locate(StandardLocation type, const QString &fileName, LocateOptions options) | - | ||||||||||||
| 410 | { | - | ||||||||||||
| 411 | const QStringList &dirs = standardLocations(type); | - | ||||||||||||
| 412 | for (QStringList::const_iterator dir = dirs.constBegin(); dir != dirs.constEnd(); ++dir) {
| 870-1743 | ||||||||||||
| 413 | const QString path = *dir + QLatin1Char('/') + fileName; | - | ||||||||||||
| 414 | if (existsAsSpecified(path, options))
| 3-1740 | ||||||||||||
| 415 | return path; executed 3 times by 2 tests: return path;Executed by:
| 3 | ||||||||||||
| 416 | } executed 1740 times by 24 tests: end of blockExecuted by:
| 1740 | ||||||||||||
| 417 | return QString(); executed 870 times by 24 tests: return QString();Executed by:
| 870 | ||||||||||||
| 418 | } | - | ||||||||||||
| 419 | - | |||||||||||||
| 420 | /*! | - | ||||||||||||
| 421 | Tries to find all files or directories called \a fileName in the standard locations | - | ||||||||||||
| 422 | for \a type. | - | ||||||||||||
| 423 | - | |||||||||||||
| 424 | The \a options flag allows to specify whether to look for files or directories. | - | ||||||||||||
| 425 | - | |||||||||||||
| 426 | Returns the list of all the files that were found. | - | ||||||||||||
| 427 | */ | - | ||||||||||||
| 428 | QStringList QStandardPaths::locateAll(StandardLocation type, const QString &fileName, LocateOptions options) | - | ||||||||||||
| 429 | { | - | ||||||||||||
| 430 | const QStringList &dirs = standardLocations(type); | - | ||||||||||||
| 431 | QStringList result; | - | ||||||||||||
| 432 | for (QStringList::const_iterator dir = dirs.constBegin(); dir != dirs.constEnd(); ++dir) {
| 141-283 | ||||||||||||
| 433 | const QString path = *dir + QLatin1Char('/') + fileName; | - | ||||||||||||
| 434 | if (existsAsSpecified(path, options))
| 83-200 | ||||||||||||
| 435 | result.append(path); executed 200 times by 3 tests: result.append(path);Executed by:
| 200 | ||||||||||||
| 436 | } executed 283 times by 4 tests: end of blockExecuted by:
| 283 | ||||||||||||
| 437 | return result; executed 141 times by 4 tests: return result;Executed by:
| 141 | ||||||||||||
| 438 | } | - | ||||||||||||
| 439 | - | |||||||||||||
| 440 | #ifdef Q_OS_WIN | - | ||||||||||||
| 441 | static QStringList executableExtensions() | - | ||||||||||||
| 442 | { | - | ||||||||||||
| 443 | // If %PATHEXT% does not contain .exe, it is either empty, malformed, or distorted in ways that we cannot support, anyway. | - | ||||||||||||
| 444 | const QStringList pathExt = QString::fromLocal8Bit(qgetenv("PATHEXT")).toLower().split(QLatin1Char(';')); | - | ||||||||||||
| 445 | return pathExt.contains(QLatin1String(".exe"), Qt::CaseInsensitive) ? | - | ||||||||||||
| 446 | pathExt : | - | ||||||||||||
| 447 | QStringList() << QLatin1String(".exe") << QLatin1String(".com") | - | ||||||||||||
| 448 | << QLatin1String(".bat") << QLatin1String(".cmd"); | - | ||||||||||||
| 449 | } | - | ||||||||||||
| 450 | #endif | - | ||||||||||||
| 451 | - | |||||||||||||
| 452 | static QString checkExecutable(const QString &path) | - | ||||||||||||
| 453 | { | - | ||||||||||||
| 454 | const QFileInfo info(path); | - | ||||||||||||
| 455 | if (info.isBundle())
| 0-168 | ||||||||||||
| 456 | return info.bundleName(); never executed: return info.bundleName(); | 0 | ||||||||||||
| 457 | if (info.isFile() && info.isExecutable())
| 0-156 | ||||||||||||
| 458 | return QDir::cleanPath(path); executed 12 times by 2 tests: return QDir::cleanPath(path);Executed by:
| 12 | ||||||||||||
| 459 | return QString(); executed 156 times by 3 tests: return QString();Executed by:
| 156 | ||||||||||||
| 460 | } | - | ||||||||||||
| 461 | - | |||||||||||||
| 462 | static inline QString searchExecutable(const QStringList &searchPaths, | - | ||||||||||||
| 463 | const QString &executableName) | - | ||||||||||||
| 464 | { | - | ||||||||||||
| 465 | const QDir currentDir = QDir::current(); | - | ||||||||||||
| 466 | foreach (const QString &searchPath, searchPaths) { | - | ||||||||||||
| 467 | const QString candidate = currentDir.absoluteFilePath(searchPath + QLatin1Char('/') + executableName); | - | ||||||||||||
| 468 | const QString absPath = checkExecutable(candidate); | - | ||||||||||||
| 469 | if (!absPath.isEmpty())
| 11-155 | ||||||||||||
| 470 | return absPath; executed 11 times by 2 tests: return absPath;Executed by:
| 11 | ||||||||||||
| 471 | } executed 155 times by 3 tests: end of blockExecuted by:
| 155 | ||||||||||||
| 472 | return QString(); executed 3 times by 2 tests: return QString();Executed by:
| 3 | ||||||||||||
| 473 | } | - | ||||||||||||
| 474 | - | |||||||||||||
| 475 | #ifdef Q_OS_WIN | - | ||||||||||||
| 476 | - | |||||||||||||
| 477 | // Find executable appending candidate suffixes, used for suffix-less executables | - | ||||||||||||
| 478 | // on Windows. | - | ||||||||||||
| 479 | static inline QString | - | ||||||||||||
| 480 | searchExecutableAppendSuffix(const QStringList &searchPaths, | - | ||||||||||||
| 481 | const QString &executableName, | - | ||||||||||||
| 482 | const QStringList &suffixes) | - | ||||||||||||
| 483 | { | - | ||||||||||||
| 484 | const QDir currentDir = QDir::current(); | - | ||||||||||||
| 485 | foreach (const QString &searchPath, searchPaths) { | - | ||||||||||||
| 486 | const QString candidateRoot = currentDir.absoluteFilePath(searchPath + QLatin1Char('/') + executableName); | - | ||||||||||||
| 487 | foreach (const QString &suffix, suffixes) { | - | ||||||||||||
| 488 | const QString absPath = checkExecutable(candidateRoot + suffix); | - | ||||||||||||
| 489 | if (!absPath.isEmpty()) | - | ||||||||||||
| 490 | return absPath; | - | ||||||||||||
| 491 | } | - | ||||||||||||
| 492 | } | - | ||||||||||||
| 493 | return QString(); | - | ||||||||||||
| 494 | } | - | ||||||||||||
| 495 | - | |||||||||||||
| 496 | #endif // Q_OS_WIN | - | ||||||||||||
| 497 | - | |||||||||||||
| 498 | /*! | - | ||||||||||||
| 499 | Finds the executable named \a executableName in the paths specified by \a paths, | - | ||||||||||||
| 500 | or the system paths if \a paths is empty. | - | ||||||||||||
| 501 | - | |||||||||||||
| 502 | On most operating systems the system path is determined by the PATH environment variable. | - | ||||||||||||
| 503 | - | |||||||||||||
| 504 | The directories where to search for the executable can be set in the \a paths argument. | - | ||||||||||||
| 505 | To search in both your own paths and the system paths, call findExecutable twice, once with | - | ||||||||||||
| 506 | \a paths set and once with \a paths empty. | - | ||||||||||||
| 507 | - | |||||||||||||
| 508 | Symlinks are not resolved, in order to preserve behavior for the case of executables | - | ||||||||||||
| 509 | whose behavior depends on the name they are invoked with. | - | ||||||||||||
| 510 | - | |||||||||||||
| 511 | \note On Windows, the usual executable extensions (from the PATHEXT environment variable) | - | ||||||||||||
| 512 | are automatically appended, so that for instance findExecutable("foo") will find foo.exe | - | ||||||||||||
| 513 | or foo.bat if present. | - | ||||||||||||
| 514 | - | |||||||||||||
| 515 | Returns the absolute file path to the executable, or an empty string if not found. | - | ||||||||||||
| 516 | */ | - | ||||||||||||
| 517 | QString QStandardPaths::findExecutable(const QString &executableName, const QStringList &paths) | - | ||||||||||||
| 518 | { | - | ||||||||||||
| 519 | if (QFileInfo(executableName).isAbsolute())
| 2-14 | ||||||||||||
| 520 | return checkExecutable(executableName); executed 2 times by 1 test: return checkExecutable(executableName);Executed by:
| 2 | ||||||||||||
| 521 | - | |||||||||||||
| 522 | QStringList searchPaths = paths; | - | ||||||||||||
| 523 | if (paths.isEmpty()) {
| 0-14 | ||||||||||||
| 524 | QByteArray pEnv = qgetenv("PATH"); | - | ||||||||||||
| 525 | // Remove trailing slashes, which occur on Windows. | - | ||||||||||||
| 526 | const QStringList rawPaths = QString::fromLocal8Bit(pEnv.constData()).split(QDir::listSeparator(), QString::SkipEmptyParts); | - | ||||||||||||
| 527 | searchPaths.reserve(rawPaths.size()); | - | ||||||||||||
| 528 | foreach (const QString &rawPath, rawPaths) { | - | ||||||||||||
| 529 | QString cleanPath = QDir::cleanPath(rawPath); | - | ||||||||||||
| 530 | if (cleanPath.size() > 1 && cleanPath.endsWith(QLatin1Char('/')))
| 0-182 | ||||||||||||
| 531 | cleanPath.truncate(cleanPath.size() - 1); never executed: cleanPath.truncate(cleanPath.size() - 1); | 0 | ||||||||||||
| 532 | searchPaths.push_back(cleanPath); | - | ||||||||||||
| 533 | } executed 182 times by 3 tests: end of blockExecuted by:
| 182 | ||||||||||||
| 534 | } executed 14 times by 3 tests: end of blockExecuted by:
| 14 | ||||||||||||
| 535 | - | |||||||||||||
| 536 | #ifdef Q_OS_WIN | - | ||||||||||||
| 537 | // On Windows, if the name does not have a suffix or a suffix not | - | ||||||||||||
| 538 | // in PATHEXT ("xx.foo"), append suffixes from PATHEXT. | - | ||||||||||||
| 539 | static const QStringList executable_extensions = executableExtensions(); | - | ||||||||||||
| 540 | if (executableName.contains(QLatin1Char('.'))) { | - | ||||||||||||
| 541 | const QString suffix = QFileInfo(executableName).suffix(); | - | ||||||||||||
| 542 | if (suffix.isEmpty() || !executable_extensions.contains(QLatin1Char('.') + suffix, Qt::CaseInsensitive)) | - | ||||||||||||
| 543 | return searchExecutableAppendSuffix(searchPaths, executableName, executable_extensions); | - | ||||||||||||
| 544 | } else { | - | ||||||||||||
| 545 | return searchExecutableAppendSuffix(searchPaths, executableName, executable_extensions); | - | ||||||||||||
| 546 | } | - | ||||||||||||
| 547 | #endif | - | ||||||||||||
| 548 | return searchExecutable(searchPaths, executableName); executed 14 times by 3 tests: return searchExecutable(searchPaths, executableName);Executed by:
| 14 | ||||||||||||
| 549 | } | - | ||||||||||||
| 550 | - | |||||||||||||
| 551 | /*! | - | ||||||||||||
| 552 | \fn QString QStandardPaths::displayName(StandardLocation type) | - | ||||||||||||
| 553 | - | |||||||||||||
| 554 | Returns a localized display name for the given location \a type or | - | ||||||||||||
| 555 | an empty QString if no relevant location can be found. | - | ||||||||||||
| 556 | */ | - | ||||||||||||
| 557 | - | |||||||||||||
| 558 | #if !defined(Q_OS_OSX) && !defined(QT_BOOTSTRAPPED) | - | ||||||||||||
| 559 | QString QStandardPaths::displayName(StandardLocation type) | - | ||||||||||||
| 560 | { | - | ||||||||||||
| 561 | switch (type) { | - | ||||||||||||
| 562 | case DesktopLocation: executed 1 time by 1 test: case DesktopLocation:Executed by:
| 1 | ||||||||||||
| 563 | return QCoreApplication::translate("QStandardPaths", "Desktop"); executed 1 time by 1 test: return QCoreApplication::translate("QStandardPaths", "Desktop");Executed by:
| 1 | ||||||||||||
| 564 | case DocumentsLocation: executed 1 time by 1 test: case DocumentsLocation:Executed by:
| 1 | ||||||||||||
| 565 | return QCoreApplication::translate("QStandardPaths", "Documents"); executed 1 time by 1 test: return QCoreApplication::translate("QStandardPaths", "Documents");Executed by:
| 1 | ||||||||||||
| 566 | case FontsLocation: executed 1 time by 1 test: case FontsLocation:Executed by:
| 1 | ||||||||||||
| 567 | return QCoreApplication::translate("QStandardPaths", "Fonts"); executed 1 time by 1 test: return QCoreApplication::translate("QStandardPaths", "Fonts");Executed by:
| 1 | ||||||||||||
| 568 | case ApplicationsLocation: executed 1 time by 1 test: case ApplicationsLocation:Executed by:
| 1 | ||||||||||||
| 569 | return QCoreApplication::translate("QStandardPaths", "Applications"); executed 1 time by 1 test: return QCoreApplication::translate("QStandardPaths", "Applications");Executed by:
| 1 | ||||||||||||
| 570 | case MusicLocation: executed 1 time by 1 test: case MusicLocation:Executed by:
| 1 | ||||||||||||
| 571 | return QCoreApplication::translate("QStandardPaths", "Music"); executed 1 time by 1 test: return QCoreApplication::translate("QStandardPaths", "Music");Executed by:
| 1 | ||||||||||||
| 572 | case MoviesLocation: executed 1 time by 1 test: case MoviesLocation:Executed by:
| 1 | ||||||||||||
| 573 | return QCoreApplication::translate("QStandardPaths", "Movies"); executed 1 time by 1 test: return QCoreApplication::translate("QStandardPaths", "Movies");Executed by:
| 1 | ||||||||||||
| 574 | case PicturesLocation: executed 1 time by 1 test: case PicturesLocation:Executed by:
| 1 | ||||||||||||
| 575 | return QCoreApplication::translate("QStandardPaths", "Pictures"); executed 1 time by 1 test: return QCoreApplication::translate("QStandardPaths", "Pictures");Executed by:
| 1 | ||||||||||||
| 576 | case TempLocation: executed 1 time by 1 test: case TempLocation:Executed by:
| 1 | ||||||||||||
| 577 | return QCoreApplication::translate("QStandardPaths", "Temporary Directory"); executed 1 time by 1 test: return QCoreApplication::translate("QStandardPaths", "Temporary Directory");Executed by:
| 1 | ||||||||||||
| 578 | case HomeLocation: executed 1 time by 1 test: case HomeLocation:Executed by:
| 1 | ||||||||||||
| 579 | return QCoreApplication::translate("QStandardPaths", "Home"); executed 1 time by 1 test: return QCoreApplication::translate("QStandardPaths", "Home");Executed by:
| 1 | ||||||||||||
| 580 | case CacheLocation: never executed: case CacheLocation: | 0 | ||||||||||||
| 581 | return QCoreApplication::translate("QStandardPaths", "Cache"); never executed: return QCoreApplication::translate("QStandardPaths", "Cache"); | 0 | ||||||||||||
| 582 | case GenericDataLocation: never executed: case GenericDataLocation: | 0 | ||||||||||||
| 583 | return QCoreApplication::translate("QStandardPaths", "Shared Data"); never executed: return QCoreApplication::translate("QStandardPaths", "Shared Data"); | 0 | ||||||||||||
| 584 | case RuntimeLocation: never executed: case RuntimeLocation: | 0 | ||||||||||||
| 585 | return QCoreApplication::translate("QStandardPaths", "Runtime"); never executed: return QCoreApplication::translate("QStandardPaths", "Runtime"); | 0 | ||||||||||||
| 586 | case ConfigLocation: never executed: case ConfigLocation: | 0 | ||||||||||||
| 587 | return QCoreApplication::translate("QStandardPaths", "Configuration"); never executed: return QCoreApplication::translate("QStandardPaths", "Configuration"); | 0 | ||||||||||||
| 588 | case GenericConfigLocation: never executed: case GenericConfigLocation: | 0 | ||||||||||||
| 589 | return QCoreApplication::translate("QStandardPaths", "Shared Configuration"); never executed: return QCoreApplication::translate("QStandardPaths", "Shared Configuration"); | 0 | ||||||||||||
| 590 | case GenericCacheLocation: never executed: case GenericCacheLocation: | 0 | ||||||||||||
| 591 | return QCoreApplication::translate("QStandardPaths", "Shared Cache"); never executed: return QCoreApplication::translate("QStandardPaths", "Shared Cache"); | 0 | ||||||||||||
| 592 | case DownloadLocation: executed 1 time by 1 test: case DownloadLocation:Executed by:
| 1 | ||||||||||||
| 593 | return QCoreApplication::translate("QStandardPaths", "Download"); executed 1 time by 1 test: return QCoreApplication::translate("QStandardPaths", "Download");Executed by:
| 1 | ||||||||||||
| 594 | case AppDataLocation: never executed: case AppDataLocation: | 0 | ||||||||||||
| 595 | case AppLocalDataLocation: executed 1 time by 1 test: case AppLocalDataLocation:Executed by:
| 1 | ||||||||||||
| 596 | return QCoreApplication::translate("QStandardPaths", "Application Data"); executed 1 time by 1 test: return QCoreApplication::translate("QStandardPaths", "Application Data");Executed by:
| 1 | ||||||||||||
| 597 | case AppConfigLocation: never executed: case AppConfigLocation: | 0 | ||||||||||||
| 598 | return QCoreApplication::translate("QStandardPaths", "Application Configuration"); never executed: return QCoreApplication::translate("QStandardPaths", "Application Configuration"); | 0 | ||||||||||||
| 599 | } | - | ||||||||||||
| 600 | // not reached | - | ||||||||||||
| 601 | return QString(); never executed: return QString(); | 0 | ||||||||||||
| 602 | } | - | ||||||||||||
| 603 | #endif | - | ||||||||||||
| 604 | - | |||||||||||||
| 605 | /*! | - | ||||||||||||
| 606 | \fn void QStandardPaths::enableTestMode(bool testMode) | - | ||||||||||||
| 607 | \obsolete Use QStandardPaths::setTestModeEnabled | - | ||||||||||||
| 608 | */ | - | ||||||||||||
| 609 | /*! | - | ||||||||||||
| 610 | \fn void QStandardPaths::setTestModeEnabled(bool testMode) | - | ||||||||||||
| 611 | - | |||||||||||||
| 612 | If \a testMode is true, this enables a special "test mode" in | - | ||||||||||||
| 613 | QStandardPaths, which changes writable locations | - | ||||||||||||
| 614 | to point to test directories, in order to prevent auto tests from reading from | - | ||||||||||||
| 615 | or writing to the current user's configuration. | - | ||||||||||||
| 616 | - | |||||||||||||
| 617 | This affects the locations into which test programs might write files: | - | ||||||||||||
| 618 | GenericDataLocation, DataLocation, ConfigLocation, GenericConfigLocation, | - | ||||||||||||
| 619 | AppConfigLocation, GenericCacheLocation, CacheLocation. | - | ||||||||||||
| 620 | Other locations are not affected. | - | ||||||||||||
| 621 | - | |||||||||||||
| 622 | On Unix, \c XDG_DATA_HOME is set to \e ~/.qttest/share, \c XDG_CONFIG_HOME is | - | ||||||||||||
| 623 | set to \e ~/.qttest/config, and \c XDG_CACHE_HOME is set to \e ~/.qttest/cache. | - | ||||||||||||
| 624 | - | |||||||||||||
| 625 | On \macos, data goes to \e ~/.qttest/Application Support, cache goes to | - | ||||||||||||
| 626 | \e ~/.qttest/Cache, and config goes to \e ~/.qttest/Preferences. | - | ||||||||||||
| 627 | - | |||||||||||||
| 628 | On Windows, everything goes to a "qttest" directory under Application Data. | - | ||||||||||||
| 629 | */ | - | ||||||||||||
| 630 | - | |||||||||||||
| 631 | static bool qsp_testMode = false; | - | ||||||||||||
| 632 | - | |||||||||||||
| 633 | #if QT_DEPRECATED_SINCE(5, 2) | - | ||||||||||||
| 634 | void QStandardPaths::enableTestMode(bool testMode) | - | ||||||||||||
| 635 | { | - | ||||||||||||
| 636 | qsp_testMode = testMode; | - | ||||||||||||
| 637 | } never executed: end of block | 0 | ||||||||||||
| 638 | #endif | - | ||||||||||||
| 639 | - | |||||||||||||
| 640 | void QStandardPaths::setTestModeEnabled(bool testMode) | - | ||||||||||||
| 641 | { | - | ||||||||||||
| 642 | qsp_testMode = testMode; | - | ||||||||||||
| 643 | } executed 7 times by 5 tests: end of blockExecuted by:
| 7 | ||||||||||||
| 644 | - | |||||||||||||
| 645 | /*! | - | ||||||||||||
| 646 | \fn void QStandardPaths::isTestModeEnabled() | - | ||||||||||||
| 647 | - | |||||||||||||
| 648 | \internal | - | ||||||||||||
| 649 | - | |||||||||||||
| 650 | Returns \c true if test mode is enabled in QStandardPaths; otherwise returns \c false. | - | ||||||||||||
| 651 | */ | - | ||||||||||||
| 652 | - | |||||||||||||
| 653 | bool QStandardPaths::isTestModeEnabled() | - | ||||||||||||
| 654 | { | - | ||||||||||||
| 655 | return qsp_testMode; executed 1153 times by 37 tests: return qsp_testMode;Executed by:
| 1153 | ||||||||||||
| 656 | } | - | ||||||||||||
| 657 | - | |||||||||||||
| 658 | - | |||||||||||||
| 659 | QT_END_NAMESPACE | - | ||||||||||||
| 660 | - | |||||||||||||
| 661 | #endif // QT_NO_STANDARDPATHS | - | ||||||||||||
| Source code | Switch to Preprocessed file |