Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qstandardpaths.cpp
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// Copyright (C) 2016 Intel Corporation.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4// Qt-Security score:critical reason:provides-trusted-directory-paths
5
7
8#include <qdir.h>
9#include <qfileinfo.h>
10#include <qvarlengtharray.h>
11
12#ifndef QT_BOOTSTRAPPED
13#include <qobject.h>
14#include <qcoreapplication.h>
15#endif
16
17#if __has_include(<paths.h>)
18#include <paths.h>
19#endif
20
21#ifdef Q_OS_UNIX
22#include <unistd.h>
23#endif
24
25#ifndef QT_NO_STANDARDPATHS
26
28
29using namespace Qt::StringLiterals;
30/*!
31 \class QStandardPaths
32 \inmodule QtCore
33 \brief The QStandardPaths class provides methods for accessing standard paths.
34 \since 5.0
35
36 This class contains functions to query standard locations on the local
37 filesystem, for common tasks such as user-specific directories or system-wide
38 configuration directories.
39*/
40
41/*!
42 \enum QStandardPaths::StandardLocation
43
44 This enum describes the different locations that can be queried using
45 methods such as QStandardPaths::writableLocation, QStandardPaths::standardLocations,
46 and QStandardPaths::displayName.
47
48 Some of the values in this enum represent a user configuration. Such enum
49 values will return the same paths in different applications, so they could
50 be used to share data with other applications. Other values are specific to
51 this application. Each enum value in the table below describes whether it's
52 application-specific or generic.
53
54 Application-specific directories should be assumed to be unreachable by
55 other applications. Therefore, files placed there might not be readable by
56 other applications, even if run by the same user. On the other hand, generic
57 directories should be assumed to be accessible by all applications run by
58 this user, but should still be assumed to be unreachable by applications by
59 other users.
60
61 Data interchange with other users is out of the scope of QStandardPaths.
62
63 \value DesktopLocation Returns the user's desktop directory. This is a generic value.
64 On systems with no concept of a desktop, this is the same as
65 QStandardPaths::HomeLocation.
66 \value DocumentsLocation Returns the directory containing user document files.
67 This is a generic value. The returned path is never empty.
68 \value FontsLocation Returns the directory containing user's fonts. This is a generic value.
69 Note that installing fonts may require additional, platform-specific operations.
70 \value ApplicationsLocation Returns the directory containing the user applications
71 (either executables, application bundles, or shortcuts to them). This is a generic value.
72 Note that installing applications may require additional, platform-specific operations.
73 Files, folders or shortcuts in this directory are platform-specific.
74 \value MusicLocation Returns the directory containing the user's music or other audio files.
75 This is a generic value. If no directory specific for music files exists, a sensible
76 fallback for storing user documents is returned.
77 \value MoviesLocation Returns the directory containing the user's movies and videos.
78 This is a generic value. If no directory specific for movie files exists, a sensible
79 fallback for storing user documents is returned.
80 \value PicturesLocation Returns the directory containing the user's pictures or photos.
81 This is a generic value. If no directory specific for picture files exists, a sensible
82 fallback for storing user documents is returned.
83 \value TempLocation Returns a directory where temporary files can be stored. The returned value
84 might be application-specific, shared among other applications for this user, or even
85 system-wide. The returned path is never empty.
86 \value HomeLocation Returns the user's home directory (the same as QDir::homePath()). On Unix
87 systems, this is equal to the HOME environment variable. This value might be
88 generic or application-specific, but the returned path is never empty.
89 \value AppLocalDataLocation Returns the local settings path on the Windows operating
90 system. On all other platforms, it returns the same value as AppDataLocation.
91 This enum value was added in Qt 5.4.
92 \value CacheLocation Returns a directory location where user-specific
93 non-essential (cached) data should be written. This is an application-specific directory.
94 The returned path is never empty.
95 \value GenericCacheLocation Returns a directory location where user-specific non-essential
96 (cached) data, shared across applications, should be written. This is a generic value.
97 Note that the returned path may be empty if the system has no concept of shared cache.
98 \value GenericDataLocation Returns a directory location where persistent
99 data shared across applications can be stored. This is a generic value. The returned
100 path is never empty.
101 \value RuntimeLocation Returns a directory location where runtime communication
102 files should be written, like Unix local sockets. This is a generic value.
103 The returned path may be empty on some systems.
104 \value ConfigLocation Returns a directory location where user-specific
105 configuration files should be written. This may be either a generic value
106 or application-specific, and the returned path is never empty.
107 \value DownloadLocation Returns a directory for user's downloaded files. This is a generic value.
108 If no directory specific for downloads exists, a sensible fallback for storing user
109 documents is returned.
110 \value GenericConfigLocation Returns a directory location where user-specific
111 configuration files shared between multiple applications should be written.
112 This is a generic value and the returned path is never empty.
113 \value AppDataLocation Returns a directory location where persistent
114 application data can be stored. This is an application-specific directory.
115 To obtain a path to store data to be shared with other applications, use
116 QStandardPaths::GenericDataLocation. The returned path is never empty.
117 On the Windows operating system, this returns the roaming path.
118 This enum value was added in Qt 5.4.
119 \value AppConfigLocation Returns a directory location where user-specific
120 configuration files should be written. This is an application-specific directory,
121 and the returned path is never empty.
122 This enum value was added in Qt 5.5.
123 \value PublicShareLocation Returns a directory location where user-specific publicly shared files
124 and directories can be stored. This is a generic value. Note that the returned path may be
125 empty if the system has no concept of a publicly shared location.
126 This enum value was added in Qt 6.4.
127 \value TemplatesLocation Returns a directory location where user-specific
128 template files can be stored. This is a generic value. Note that the returned path may be
129 empty if the system has no concept of a templates location.
130 This enum value was added in Qt 6.4.
131 \value [since 6.7] StateLocation Returns a directory location where user-specific application
132 state data files should be written. This is an application-specific directory,
133 and the returned path is never empty.
134 \value [since 6.7] GenericStateLocation Returns a directory location where shared state data files
135 across applications should be written. This value might be generic or application-specific,
136 but the returned path is never empty.
137
138 The following table gives examples of paths on different operating systems.
139 The first path is the writable path (unless noted). Other, additional
140 paths, if any, represent non-writable locations.
141
142 \table
143 \header \li Path type \li \macos \li Windows
144 \row \li DesktopLocation
145 \li "~/Desktop"
146 \li "C:/Users/<USER>/Desktop"
147 \row \li DocumentsLocation
148 \li "~/Documents"
149 \li "C:/Users/<USER>/Documents"
150 \row \li FontsLocation
151 \li "/System/Library/Fonts" (not writable)
152 \li "C:/Windows/Fonts" (not writable)
153 \row \li ApplicationsLocation
154 \li "/Applications" (not writable)
155 \li "C:/Users/<USER>/AppData/Roaming/Microsoft/Windows/Start Menu/Programs"
156 \row \li MusicLocation
157 \li "~/Music"
158 \li "C:/Users/<USER>/Music"
159 \row \li MoviesLocation
160 \li "~/Movies"
161 \li "C:/Users/<USER>/Videos"
162 \row \li PicturesLocation
163 \li "~/Pictures"
164 \li "C:/Users/<USER>/Pictures"
165 \row \li TempLocation
166 \li randomly generated by the OS
167 \li "C:/Users/<USER>/AppData/Local/Temp"
168 \row \li HomeLocation
169 \li "~"
170 \li "C:/Users/<USER>"
171 \row \li AppLocalDataLocation
172 \li "~/Library/Application Support/<APPNAME>", "/Library/Application Support/<APPNAME>". "<APPDIR>/../Resources"
173 \li "C:/Users/<USER>/AppData/Local/<APPNAME>", "C:/ProgramData/<APPNAME>", "<APPDIR>", "<APPDIR>/data", "<APPDIR>/data/<APPNAME>"
174 \row \li CacheLocation
175 \li "~/Library/Caches/<APPNAME>", "/Library/Caches/<APPNAME>"
176 \li "C:/Users/<USER>/AppData/Local/<APPNAME>/cache"
177 \row \li StateLocation
178 \li "~/Library/Preferences/<APPNAME>/State"
179 \li "C:/Users/<USER>/AppData/Local/<APPNAME>/State", "C:/ProgramData/<APPNAME>/State"
180 \row \li GenericDataLocation
181 \li "~/Library/Application Support", "/Library/Application Support"
182 \li "C:/Users/<USER>/AppData/Local", "C:/ProgramData", "<APPDIR>", "<APPDIR>/data"
183 \row \li RuntimeLocation
184 \li "~/Library/Application Support"
185 \li "C:/Users/<USER>"
186 \row \li ConfigLocation
187 \li "~/Library/Preferences"
188 \li "C:/Users/<USER>/AppData/Local/<APPNAME>", "C:/ProgramData/<APPNAME>"
189 \row \li GenericConfigLocation
190 \li "~/Library/Preferences"
191 \li "C:/Users/<USER>/AppData/Local", "C:/ProgramData"
192 \row \li DownloadLocation
193 \li "~/Downloads"
194 \li "C:/Users/<USER>/Downloads"
195 \row \li GenericCacheLocation
196 \li "~/Library/Caches", "/Library/Caches"
197 \li "C:/Users/<USER>/AppData/Local/cache"
198 \row \li GenericStateLocation
199 \li "~/Library/Preferences/State"
200 \li "C:/Users/<USER>/AppData/Local/State", "C:/ProgramData/State"
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", "<APPDIR>/data/<APPNAME>"
204 \row \li AppConfigLocation
205 \li "~/Library/Preferences/<APPNAME>"
206 \li "C:/Users/<USER>/AppData/Local/<APPNAME>", "C:/ProgramData/<APPNAME>"
207 \row \li PublicShareLocation
208 \li "~/Public"
209 \li "C:/Users/Public"
210 \row \li TemplatesLocation
211 \li "~/Templates"
212 \li "C:/Users/<USER>/AppData/Roaming/Microsoft/Windows/Templates"
213 \endtable
214
215 \table
216 \header \li Path type \li Linux and other UNIX operating systems
217 \row \li DesktopLocation
218 \li "~/Desktop"
219 \row \li DocumentsLocation
220 \li "~/Documents"
221 \row \li FontsLocation
222 \li "~/.fonts", "~/.local/share/fonts", "/usr/local/share/fonts", "/usr/share/fonts"
223 \row \li ApplicationsLocation
224 \li "~/.local/share/applications", "/usr/local/share/applications", "/usr/share/applications"
225 \row \li MusicLocation
226 \li "~/Music"
227 \row \li MoviesLocation
228 \li "~/Videos"
229 \row \li PicturesLocation
230 \li "~/Pictures"
231 \row \li TempLocation
232 \li "/tmp"
233 \row \li HomeLocation
234 \li "~"
235 \row \li AppLocalDataLocation
236 \li "~/.local/share/<APPNAME>", "/usr/local/share/<APPNAME>", "/usr/share/<APPNAME>"
237 \row \li CacheLocation
238 \li "~/.cache/<APPNAME>"
239 \row \li StateLocation
240 \li "~/.local/state/<APPNAME>"
241 \row \li GenericDataLocation
242 \li "~/.local/share", "/usr/local/share", "/usr/share"
243 \row \li RuntimeLocation
244 \li "/run/user/<USER>"
245 \row \li ConfigLocation
246 \li "~/.config", "/etc/xdg"
247 \row \li GenericConfigLocation
248 \li "~/.config", "/etc/xdg"
249 \row \li DownloadLocation
250 \li "~/Downloads"
251 \row \li GenericCacheLocation
252 \li "~/.cache"
253 \row \li GenericStateLocation
254 \li "~/.local/state"
255 \row \li AppDataLocation
256 \li "~/.local/share/<APPNAME>", "/usr/local/share/<APPNAME>", "/usr/share/<APPNAME>"
257 \row \li AppConfigLocation
258 \li "~/.config/<APPNAME>", "/etc/xdg/<APPNAME>"
259 \row \li PublicShareLocation
260 \li "~/Public"
261 \row \li TemplatesLocation
262 \li "~/Templates"
263 \endtable
264
265 \table
266 \header \li Path type \li Android \li iOS
267 \row \li DesktopLocation
268 \li "<APPROOT>/files"
269 \li "<APPROOT>/Documents/Desktop"
270 \row \li DocumentsLocation
271 \li "<USER>/Documents" [*], "<USER>/<APPNAME>/Documents"
272 \li "<APPROOT>/Documents"
273 \row \li FontsLocation
274 \li "/system/fonts" (not writable)
275 \li "<APPROOT>/Library/Fonts"
276 \row \li ApplicationsLocation
277 \li not supported (directory not readable)
278 \li not supported
279 \row \li MusicLocation
280 \li "<USER>/Music" [*], "<USER>/<APPNAME>/Music"
281 \li "<APPROOT>/Documents/Music"
282 \row \li MoviesLocation
283 \li "<USER>/Movies" [*], "<USER>/<APPNAME>/Movies"
284 \li "<APPROOT>/Documents/Movies"
285 \row \li PicturesLocation
286 \li "<USER>/Pictures" [*], "<USER>/<APPNAME>/Pictures"
287 \li "<APPROOT>/Documents/Pictures", "assets-library://"
288 \row \li TempLocation
289 \li "<APPROOT>/cache"
290 \li "<APPROOT>/tmp"
291 \row \li HomeLocation
292 \li "<APPROOT>/files"
293 \li system defined
294 \row \li AppLocalDataLocation
295 \li "<APPROOT>/files", "<USER>/<APPNAME>/files"
296 \li "<APPROOT>/Library/Application Support"
297 \row \li CacheLocation
298 \li "<APPROOT>/cache", "<USER>/<APPNAME>/cache"
299 \li "<APPROOT>/Library/Caches"
300 \row \li StateLocation
301 \li "<APPROOT>/files/state"
302 \row \li GenericStateLocation (there is shared state)
303 \li "<APPROOT>/files/state"
304 \row \li GenericDataLocation
305 \li "<USER>" [*] or "<USER>/<APPNAME>/files"
306 \li "<APPROOT>/Library/Application Support"
307 \row \li RuntimeLocation
308 \li "<APPROOT>/cache"
309 \li not supported
310 \row \li ConfigLocation
311 \li "<APPROOT>/files/settings"
312 \li "<APPROOT>/Library/Preferences"
313 \row \li GenericConfigLocation
314 \li "<APPROOT>/files/settings" (there is no shared settings)
315 \li "<APPROOT>/Library/Preferences"
316 \row \li DownloadLocation
317 \li "<USER>/Downloads" [*], "<USER>/<APPNAME>/Downloads"
318 \li "<APPROOT>/Documents/Downloads"
319 \row \li GenericCacheLocation
320 \li "<APPROOT>/cache" (there is no shared cache)
321 \li "<APPROOT>/Library/Caches"
322 \row \li AppDataLocation
323 \li "<APPROOT>/files", "<USER>/<APPNAME>/files"
324 \li "<APPROOT>/Library/Application Support"
325 \row \li AppConfigLocation
326 \li "<APPROOT>/files/settings"
327 \li "<APPROOT>/Library/Preferences/<APPNAME>"
328 \row \li PublicShareLocation
329 \li not supported
330 \li not supported
331 \row \li TemplatesLocation
332 \li not supported
333 \li not supported
334 \endtable
335
336 In the table above, \c <APPNAME> is usually the organization name, the
337 application name, or both, or a unique name generated at packaging.
338 Similarly, <APPROOT> is the location where this application is installed
339 (often a sandbox). <APPDIR> is the directory containing the application
340 executable.
341
342 The paths above should not be relied upon, as they may change according to
343 OS configuration, locale, or they may change in future Qt versions.
344
345 \note On Android, applications with open files on the external storage (<USER> locations),
346 will be killed if the external storage is unmounted.
347
348 \note On Android 6.0 (API 23) or higher, the "WRITE_EXTERNAL_STORAGE" permission must be
349 requested at runtime when using QStandardPaths::writableLocation or QStandardPaths::standardLocations.
350
351 \note On Android, reading/writing to GenericDataLocation needs the READ_EXTERNAL_STORAGE/WRITE_EXTERNAL_STORAGE permission granted.
352
353 \note [*] On Android 11 and above, public directories are no longer directly accessible
354 in scoped storage mode. Thus, paths of the form \c "<USER>/DirName" are not returned.
355 Instead, you can use \l QFileDialog which uses the Storage Access Framework (SAF)
356 to access such directories.
357
358 \note On iOS, if you do pass \c {QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).last()}
359 as argument to \l{QFileDialog::setDirectory()},
360 a native image picker dialog will be used for accessing the user's photo album.
361 The filename returned can be loaded using QFile and related APIs.
362 This feature was added in Qt 5.5.
363
364 \sa writableLocation(), standardLocations(), displayName(), locate(), locateAll()
365*/
366
367/*!
368 \fn QString QStandardPaths::writableLocation(StandardLocation type)
369
370 \include standardpath/functiondocs.qdocinc writableLocation
371*/
372
373
374/*!
375 \fn QStringList QStandardPaths::standardLocations(StandardLocation type)
376
377 \include standardpath/functiondocs.qdocinc standardLocations
378
379 \sa writableLocation()
380 */
381
382/*!
383 \enum QStandardPaths::LocateOption
384
385 This enum describes the different flags that can be used for
386 controlling the behavior of QStandardPaths::locate and
387 QStandardPaths::locateAll.
388
389 \value LocateFile return only files
390 \value LocateDirectory return only directories
391*/
392
393static bool existsAsSpecified(const QString &path, QStandardPaths::LocateOptions options)
394{
395 if (options & QStandardPaths::LocateDirectory)
396 return QDir(path).exists();
397 return QFileInfo(path).isFile();
398}
399
400/*!
401 \include standardpath/functiondocs.qdocinc locate
402 */
403QString QStandardPaths::locate(StandardLocation type, const QString &fileName, LocateOptions options)
404{
405 const QStringList &dirs = standardLocations(type);
406 for (QStringList::const_iterator dir = dirs.constBegin(); dir != dirs.constEnd(); ++dir) {
407 const QString path = *dir + u'/' + fileName;
408 if (existsAsSpecified(path, options))
409 return path;
410 }
411 return QString();
412}
413
414/*!
415 \include standardpath/functiondocs.qdocinc locateAll
416 */
417QStringList QStandardPaths::locateAll(StandardLocation type, const QString &fileName, LocateOptions options)
418{
419 const QStringList &dirs = standardLocations(type);
420 QStringList result;
421 for (QStringList::const_iterator dir = dirs.constBegin(); dir != dirs.constEnd(); ++dir) {
422 const QString path = *dir + u'/' + fileName;
423 if (existsAsSpecified(path, options))
424 result.append(path);
425 }
426 return result;
427}
428
429static Q_DECL_COLD_FUNCTION QString fallbackPathVariable()
430{
431#if defined(_PATH_DEFPATH)
432 // BSD API.
433 return QString::fromLocal8Bit(_PATH_DEFPATH);
434#endif
435#if defined(_CS_PATH)
436 // POSIX API.
437 size_t n = confstr(_CS_PATH, nullptr, 0);
438 if (n) {
439 // n includes the terminating null
440 QVarLengthArray<char, 1024> rawpath(n);
441 confstr(_CS_PATH, rawpath.data(), n);
442 return QString::fromLocal8Bit(QByteArrayView(rawpath.data(), n - 1));
443 }
444#else
445 // Windows SDK's execvpe() does not have a fallback, so we won't
446 // apply one either.
447#endif
448 return {};
449}
450
451#ifdef Q_OS_WIN
452static QStringList executableExtensions()
453{
454 // If %PATHEXT% does not contain .exe, it is either empty, malformed, or distorted in ways that we cannot support, anyway.
455 const QStringList pathExt = QString::fromLocal8Bit(qgetenv("PATHEXT")).toLower().split(u';');
456 return pathExt.contains(".exe"_L1, Qt::CaseInsensitive) ?
457 pathExt : QStringList{".exe"_L1, ".com"_L1, ".bat"_L1, ".cmd"_L1};
458}
459#endif
460
461static QString checkExecutable(const QString &path)
462{
463 const QFileInfo info(path);
464 if (info.isBundle())
465 return info.bundleName();
466 if (info.isFile() && info.isExecutable())
467 return QDir::cleanPath(path);
468 return QString();
469}
470
471static inline QString searchExecutable(const QStringList &searchPaths,
472 const QString &executableName)
473{
474 const QDir currentDir = QDir::current();
475 for (const QString &searchPath : searchPaths) {
476 const QString candidate = currentDir.absoluteFilePath(searchPath + u'/' + executableName);
477 const QString absPath = checkExecutable(candidate);
478 if (!absPath.isEmpty())
479 return absPath;
480 }
481 return QString();
482}
483
484#ifdef Q_OS_WIN
485
486// Find executable appending candidate suffixes, used for suffix-less executables
487// on Windows.
488static inline QString
489 searchExecutableAppendSuffix(const QStringList &searchPaths,
490 const QString &executableName,
491 const QStringList &suffixes)
492{
493 const QDir currentDir = QDir::current();
494 for (const QString &searchPath : searchPaths) {
495 const QString candidateRoot = currentDir.absoluteFilePath(searchPath + u'/' + executableName);
496 for (const QString &suffix : suffixes) {
497 const QString absPath = checkExecutable(candidateRoot + suffix);
498 if (!absPath.isEmpty())
499 return absPath;
500 }
501 }
502 return QString();
503}
504
505#endif // Q_OS_WIN
506
507/*!
508 \include standardpath/functiondocs.qdocinc findExecutable
509 */
510QString QStandardPaths::findExecutable(const QString &executableName, const QStringList &paths)
511{
512 if (QFileInfo(executableName).isAbsolute())
513 return checkExecutable(executableName);
514
515 QStringList searchPaths = paths;
516 if (paths.isEmpty()) {
517 QString pEnv = qEnvironmentVariable("PATH");
518 if (Q_UNLIKELY(pEnv.isNull())) {
519 // Get a default path. POSIX.1 does not actually require this, but
520 // most Unix libc fall back to confstr(_CS_PATH) if the PATH
521 // environment variable isn't set. Let's try to do the same.
522 pEnv = fallbackPathVariable();
523 }
524
525 // Remove trailing slashes, which occur on Windows.
526 searchPaths.reserve(pEnv.count(QDir::listSeparator()));
527 auto tokenizer = qTokenize(pEnv, QDir::listSeparator(), Qt::SkipEmptyParts);
528 for (QStringView rawPath : tokenizer) {
529 QString cleanPath = QDir::cleanPath(rawPath.toString());
530 if (cleanPath.size() > 1 && cleanPath.endsWith(u'/'))
531 cleanPath.truncate(cleanPath.size() - 1);
532 searchPaths.push_back(cleanPath);
533 }
534 }
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(u'.')) {
541 const QString suffix = QFileInfo(executableName).suffix();
542 if (suffix.isEmpty() || !executable_extensions.contains(u'.' + 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);
549}
550
551/*!
552 \fn QString QStandardPaths::displayName(StandardLocation type)
553
554 \include standardpath/functiondocs.qdocinc displayName
555*/
556
557#if !defined(Q_OS_DARWIN) && !defined(QT_BOOTSTRAPPED)
558QString QStandardPaths::displayName(StandardLocation type)
559{
560 switch (type) {
561 case DesktopLocation:
562 return QCoreApplication::translate("QStandardPaths", "Desktop");
563 case DocumentsLocation:
564 return QCoreApplication::translate("QStandardPaths", "Documents");
565 case FontsLocation:
566 return QCoreApplication::translate("QStandardPaths", "Fonts");
567 case ApplicationsLocation:
568 return QCoreApplication::translate("QStandardPaths", "Applications");
569 case MusicLocation:
570 return QCoreApplication::translate("QStandardPaths", "Music");
571 case MoviesLocation:
572 return QCoreApplication::translate("QStandardPaths", "Movies");
573 case PicturesLocation:
574 return QCoreApplication::translate("QStandardPaths", "Pictures");
575 case TempLocation:
576 return QCoreApplication::translate("QStandardPaths", "Temporary Directory");
577 case HomeLocation:
578 return QCoreApplication::translate("QStandardPaths", "Home");
579 case AppLocalDataLocation:
580 return QCoreApplication::translate("QStandardPaths", "Application Data");
581 case CacheLocation:
582 return QCoreApplication::translate("QStandardPaths", "Cache");
583 case StateLocation:
584 return QCoreApplication::translate("QStandardPaths", "State");
585 case GenericDataLocation:
586 return QCoreApplication::translate("QStandardPaths", "Shared Data");
587 case RuntimeLocation:
588 return QCoreApplication::translate("QStandardPaths", "Runtime");
589 case ConfigLocation:
590 return QCoreApplication::translate("QStandardPaths", "Configuration");
591 case GenericConfigLocation:
592 return QCoreApplication::translate("QStandardPaths", "Shared Configuration");
593 case GenericCacheLocation:
594 return QCoreApplication::translate("QStandardPaths", "Shared Cache");
595 case GenericStateLocation:
596 return QCoreApplication::translate("QStandardPaths", "Shared State");
597 case DownloadLocation:
598 return QCoreApplication::translate("QStandardPaths", "Downloads");
599 case AppDataLocation:
600 case AppConfigLocation:
601 return QCoreApplication::translate("QStandardPaths", "Application Configuration");
602 case PublicShareLocation:
603 return QCoreApplication::translate("QStandardPaths", "Public");
604 case TemplatesLocation:
605 return QCoreApplication::translate("QStandardPaths", "Templates");
606 }
607 // not reached
608 return QString();
609}
610#endif
611
612/*!
613 \fn void QStandardPaths::setTestModeEnabled(bool testMode)
614
615 \include standardpath/functiondocs.qdocinc setTestModeEnabled
616*/
617
618Q_CONSTINIT static bool qsp_testMode = false;
619
620void QStandardPaths::setTestModeEnabled(bool testMode)
621{
622 qsp_testMode = testMode;
623}
624
625/*!
626 \fn void QStandardPaths::isTestModeEnabled()
627
628 \internal
629
630 Returns \c true if test mode is enabled in QStandardPaths; otherwise returns \c false.
631*/
632
633bool QStandardPaths::isTestModeEnabled()
634{
635 return qsp_testMode;
636}
637
638
639QT_END_NAMESPACE
640
641#ifndef QT_NO_QOBJECT
642#include "moc_qstandardpaths.cpp"
643#endif
644
645#endif // QT_NO_STANDARDPATHS
#define __has_include(x)
static bool existsAsSpecified(const QString &path, QStandardPaths::LocateOptions options)
static QString searchExecutable(const QStringList &searchPaths, const QString &executableName)
static Q_CONSTINIT bool qsp_testMode
static QString checkExecutable(const QString &path)
#define _PATH_DEFPATH