Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qstandardpaths_haiku.cpp
Go to the documentation of this file.
1// Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qstandardpaths.h"
5
6#ifndef QT_NO_STANDARDPATHS
7
8#ifndef QT_BOOTSTRAPPED
9#include <qcoreapplication.h>
10#endif
11
12#include <qfile.h>
13
14#include <FindDirectory.h>
15#include <Path.h>
16#include <PathFinder.h>
17#include <StringList.h>
18
20
21namespace {
22
24{
25#ifndef QT_BOOTSTRAPPED
27 if (!org.isEmpty())
28 path += u'/' + org;
30 if (!appName.isEmpty())
31 path += u'/' + appName;
32#else
34#endif
35}
36
37/*
38 * Returns the generic standard path for given directory type.
39 */
40QString haikuStandardPath(directory_which which)
41{
42 BPath standardPath;
43
44 if (find_directory(which, &standardPath, false) != B_OK)
45 return QString();
46
47 return QFile::decodeName(standardPath.Path());
48}
49
50/*
51 * Returns the generic standard paths for given path type.
52 */
53QStringList haikuStandardPaths(path_base_directory baseDirectory)
54{
55 BStringList paths;
56
57 if (BPathFinder::FindPaths(baseDirectory, paths) != B_OK)
58 return QStringList();
59
60 QStringList standardPaths;
61 for (int i = 0; i < paths.CountStrings(); ++i) {
62 standardPaths << QFile::decodeName(paths.StringAt(i).String());
63 }
64
65 return standardPaths;
66}
67
68/*
69 * Returns the application specific standard path for given directory type.
70 */
71QString haikuAppStandardPath(directory_which which)
72{
74 if (!path.isEmpty())
76
77 return path;
78}
79
80/*
81 * Returns the application specific standard paths for given path type.
82 */
83QStringList haikuAppStandardPaths(path_base_directory baseDirectory)
84{
85 QStringList paths = haikuStandardPaths(baseDirectory);
86 for (int i = 0; i < paths.count(); ++i)
88
89 return paths;
90}
91
92} // namespace
93
95{
96 switch (type) {
97 case DesktopLocation:
98 return haikuStandardPath(B_DESKTOP_DIRECTORY);
99 case DocumentsLocation: // fall through
100 case PicturesLocation:
101 case MusicLocation:
102 case MoviesLocation:
103 case DownloadLocation:
106 case HomeLocation:
107 return haikuStandardPath(B_USER_DIRECTORY);
108 case FontsLocation:
109 return haikuStandardPath(B_USER_NONPACKAGED_FONTS_DIRECTORY);
111 return haikuStandardPath(B_USER_NONPACKAGED_BIN_DIRECTORY);
112 case TempLocation:
113 return haikuStandardPath(B_SYSTEM_TEMP_DIRECTORY);
114 case AppDataLocation: // fall through
116 return haikuAppStandardPath(B_USER_NONPACKAGED_DATA_DIRECTORY);
118 return haikuStandardPath(B_USER_NONPACKAGED_DATA_DIRECTORY);
119 case CacheLocation:
120 return haikuAppStandardPath(B_USER_CACHE_DIRECTORY);
122 return haikuStandardPath(B_USER_CACHE_DIRECTORY);
123 case ConfigLocation:
125 case StateLocation:
127 return haikuAppStandardPath(B_USER_SETTINGS_DIRECTORY);
129 return haikuStandardPath(B_USER_SETTINGS_DIRECTORY);
130 default:
131 return QString();
132 }
133}
134
136{
138
139 const QString writablePath = writableLocation(type);
140 if (!writablePath.isEmpty())
141 paths += writablePath;
142
143 switch (type) {
144 case DocumentsLocation: // fall through
145 case PicturesLocation:
146 case MusicLocation:
147 case MoviesLocation:
148 case DownloadLocation:
151 case HomeLocation:
152 paths += haikuStandardPath(B_USER_NONPACKAGED_DIRECTORY);
153 break;
154 case FontsLocation:
155 paths += haikuStandardPaths(B_FIND_PATH_FONTS_DIRECTORY);
156 break;
158 paths += haikuStandardPaths(B_FIND_PATH_BIN_DIRECTORY);
159 paths += haikuStandardPaths(B_FIND_PATH_APPS_DIRECTORY);
160 break;
161 case AppDataLocation: // fall through
163 paths += haikuAppStandardPaths(B_FIND_PATH_DATA_DIRECTORY);
164 break;
166 paths += haikuStandardPaths(B_FIND_PATH_DATA_DIRECTORY);
167 break;
168 case CacheLocation:
169 paths += haikuAppStandardPath(B_SYSTEM_CACHE_DIRECTORY);
170 break;
172 paths += haikuStandardPath(B_SYSTEM_CACHE_DIRECTORY);
173 break;
174 case ConfigLocation: // fall through
176 paths += haikuAppStandardPath(B_SYSTEM_SETTINGS_DIRECTORY);
177 break;
179 paths += haikuStandardPath(B_SYSTEM_SETTINGS_DIRECTORY);
180 break;
181 default:
182 break;
183 }
184
185 return paths;
186}
187
189
190#endif // QT_NO_STANDARDPATHS
QString organizationName
the name of the organization that wrote this application
QString applicationName
the name of this application
static QString decodeName(const QByteArray &localFileName)
This does the reverse of QFile::encodeName() using localFileName.
Definition qfile.h:162
static QStringList standardLocations(StandardLocation type)
static QString writableLocation(StandardLocation type)
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
Combined button and popup list for selecting options.
QString haikuAppStandardPath(directory_which which)
QString haikuStandardPath(directory_which which)
QStringList haikuStandardPaths(path_base_directory baseDirectory)
QStringList haikuAppStandardPaths(path_base_directory baseDirectory)
QList< QString > QStringList
Constructs a string list that contains the given string, str.
GLenum type
GLsizei const GLuint * paths
GLsizei const GLchar *const * path
static void appendOrganizationAndApp(QString &path)
#define Q_UNUSED(x)