\table
\header \li Path type \li Linux (including Android)
\row \li DesktopLocation
- \li "<APPROOT>/data"
\li "~/Desktop"
\row \li DocumentsLocation
- \li "<APPROOT>/shared/documents"
\li "~/Documents"
\row \li FontsLocation
- \li "/base/usr/fonts" (not writable)
\li "~/.fonts"
\row \li ApplicationsLocation
- \li not supported (directory not readable)
\li "~/.local/share/applications", "/usr/local/share/applications", "/usr/share/applications"
\row \li MusicLocation
- \li "<APPROOT>/shared/music"
\li "~/Music"
\row \li MoviesLocation
- \li "<APPROOT>/shared/videos"
\li "~/Videos"
\row \li PicturesLocation
- \li "<APPROOT>/shared/photos"
\li "~/Pictures"
\row \li TempLocation
\li "/var/tmp"
\li "/tmp"
\row \li HomeLocation
- \li "<APPROOT>/data"
\li "~"
\row \li DataLocation
- \li "<APPROOT>/data", "<APPROOT>/app/native/assets"
\li "~/.local/share/<APPNAME>", "/usr/local/share/<APPNAME>", "/usr/share/<APPNAME>"
\row \li CacheLocation
- \li "<APPROOT>/data/Cache"
\li "~/.cache/<APPNAME>"
\row \li GenericDataLocation
- \li "<APPROOT>/shared/misc"
\li "~/.local/share", "/usr/local/share", "/usr/share"
\row \li RuntimeLocation
\li "/var/tmp"
\li "/run/user/<USER>"
\row \li ConfigLocation
- \li "<APPROOT>/data/Settings"
\li "~/.config", "/etc/xdg"
\row \li GenericConfigLocation
- \li "<APPROOT>/data/Settings"
\li "~/.config", "/etc/xdg"
\row \li DownloadLocation
- \li "<APPROOT>/shared/downloads"
\li "~/Downloads"
\row \li GenericCacheLocation
- \li "<APPROOT>/data/Cache" (there is no shared cache)
\li "~/.cache"
\endtable
may need to be created by the system or the user.
*/
-
/*!
\fn QStringList QStandardPaths::standardLocations(StandardLocation type)
\value LocateDirectory return only directories
*/
-static bool existsAsSpecified(const QString &path, QStandardPaths::LocateOptions options)
+static inline bool existsAsSpecified(const QString &path, QStandardPaths::LocateOption options)
{
- if (options & QStandardPaths::LocateDirectory) {
+ if (options == QStandardPaths::LocateDirectory) {
return QDir(path).exists();
}
return QFileInfo(path).isFile();
}
+static inline QString checkExecutable(const QString &path)
+{
+ const QFileInfo info(path);
+ if (info.isFile() && info.isExecutable()) {
+ return QDir::cleanPath(path);
+ }
+ return QString();
+}
+
+static inline QString searchExecutable(const QStringList &searchPaths,
+ const QString &executableName)
+{
+ const QDir currentDir = QDir::current();
+ foreach (const QString &searchPath, searchPaths) {
+ const QString candidate = currentDir.absoluteFilePath(searchPath + QLatin1Char('/') + executableName);
+ const QString absPath = checkExecutable(QDir::cleanPath(candidate));
+ if (!absPath.isEmpty()) {
+ return absPath;
+ }
+ }
+ return QString();
+}
+
/*!
Tries to find a file or directory called \a fileName in the standard locations
for \a type.
The full path to the first file or directory (depending on \a options) found is returned.
If no such file or directory can be found, an empty string is returned.
*/
-QString QStandardPaths::locate(StandardLocation type, const QString &fileName, LocateOptions options)
+QString QStandardPaths::locate(StandardLocation type, const QString &fileName, LocateOption options)
{
foreach (const QString &dir, standardLocations(type)) {
const QString path = dir + QLatin1Char('/') + fileName;
Returns the list of all the files that were found.
*/
-QStringList QStandardPaths::locateAll(StandardLocation type, const QString &fileName, LocateOptions options)
+QStringList QStandardPaths::locateAll(StandardLocation type, const QString &fileName, LocateOption options)
{
QStringList result;
foreach (const QString &dir, standardLocations(type)) {
return result;
}
-static QString checkExecutable(const QString &path)
-{
- const QFileInfo info(path);
- if (info.isFile() && info.isExecutable()) {
- return QDir::cleanPath(path);
- }
- return QString();
-}
-
-static inline QString searchExecutable(const QStringList &searchPaths,
- const QString &executableName)
-{
- const QDir currentDir = QDir::current();
- foreach (const QString &searchPath, searchPaths) {
- const QString candidate = currentDir.absoluteFilePath(searchPath + QLatin1Char('/') + executableName);
- const QString absPath = checkExecutable(QDir::cleanPath(candidate));
- if (!absPath.isEmpty()) {
- return absPath;
- }
- }
- return QString();
-}
-
/*!
Finds the executable named \a executableName in the paths specified by \a paths,
or the system paths if \a paths is empty.
GenericConfigLocation
};
- static QString writableLocation(StandardLocation type);
- static QStringList standardLocations(StandardLocation type);
-
enum LocateOption {
LocateFile = 0x0,
LocateDirectory = 0x1
};
- Q_DECLARE_FLAGS(LocateOptions, LocateOption);
- static QString locate(StandardLocation type, const QString &fileName, LocateOptions options = LocateFile);
- static QStringList locateAll(StandardLocation type, const QString &fileName, LocateOptions options = LocateFile);
+ static QString writableLocation(StandardLocation type);
+ static QStringList standardLocations(StandardLocation type);
+
+ static QString locate(StandardLocation type, const QString &fileName, LocateOption options = LocateFile);
+ static QStringList locateAll(StandardLocation type, const QString &fileName, LocateOption options = LocateFile);
static QString displayName(StandardLocation type);
static QString findExecutable(const QString &executableName, const QStringList &paths = QStringList());