QtBase  v6.3.1
qstandardpaths_haiku.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 **
3 ** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
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 https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://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 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #include "qstandardpaths.h"
41 
42 #ifndef QT_NO_STANDARDPATHS
43 
44 #ifndef QT_BOOTSTRAPPED
45 #include <qcoreapplication.h>
46 #endif
47 
48 #include <qfile.h>
49 
50 #include <FindDirectory.h>
51 #include <Path.h>
52 #include <PathFinder.h>
53 #include <StringList.h>
54 
56 
57 namespace {
58 
60 {
61 #ifndef QT_BOOTSTRAPPED
63  if (!org.isEmpty())
64  path += QLatin1Char('/') + org;
66  if (!appName.isEmpty())
67  path += QLatin1Char('/') + appName;
68 #else
69  Q_UNUSED(path);
70 #endif
71 }
72 
73 /*
74  * Returns the generic standard path for given directory type.
75  */
76 QString haikuStandardPath(directory_which which)
77 {
78  BPath standardPath;
79 
80  if (find_directory(which, &standardPath, false) != B_OK)
81  return QString();
82 
83  return QFile::decodeName(standardPath.Path());
84 }
85 
86 /*
87  * Returns the generic standard paths for given path type.
88  */
89 QStringList haikuStandardPaths(path_base_directory baseDirectory)
90 {
91  BStringList paths;
92 
93  if (BPathFinder::FindPaths(baseDirectory, paths) != B_OK)
94  return QStringList();
95 
96  QStringList standardPaths;
97  for (int i = 0; i < paths.CountStrings(); ++i) {
98  standardPaths << QFile::decodeName(paths.StringAt(i).String());
99  }
100 
101  return standardPaths;
102 }
103 
104 /*
105  * Returns the application specific standard path for given directory type.
106  */
107 QString haikuAppStandardPath(directory_which which)
108 {
109  QString path = haikuStandardPath(which);
110  if (!path.isEmpty())
112 
113  return path;
114 }
115 
116 /*
117  * Returns the application specific standard paths for given path type.
118  */
119 QStringList haikuAppStandardPaths(path_base_directory baseDirectory)
120 {
121  QStringList paths = haikuStandardPaths(baseDirectory);
122  for (int i = 0; i < paths.count(); ++i)
124 
125  return paths;
126 }
127 
128 } // namespace
129 
131 {
132  switch (type) {
133  case DesktopLocation:
134  return haikuStandardPath(B_DESKTOP_DIRECTORY);
135  case DocumentsLocation: // fall through
136  case PicturesLocation:
137  case MusicLocation:
138  case MoviesLocation:
139  case DownloadLocation:
140  case HomeLocation:
141  return haikuStandardPath(B_USER_DIRECTORY);
142  case FontsLocation:
143  return haikuStandardPath(B_USER_NONPACKAGED_FONTS_DIRECTORY);
145  return haikuStandardPath(B_USER_NONPACKAGED_BIN_DIRECTORY);
146  case TempLocation:
147  return haikuStandardPath(B_SYSTEM_TEMP_DIRECTORY);
148  case AppDataLocation: // fall through
150  return haikuAppStandardPath(B_USER_NONPACKAGED_DATA_DIRECTORY);
151  case GenericDataLocation:
152  return haikuStandardPath(B_USER_NONPACKAGED_DATA_DIRECTORY);
153  case CacheLocation:
154  return haikuAppStandardPath(B_USER_CACHE_DIRECTORY);
156  return haikuStandardPath(B_USER_CACHE_DIRECTORY);
157  case ConfigLocation: // fall through
158  case AppConfigLocation:
159  return haikuAppStandardPath(B_USER_SETTINGS_DIRECTORY);
161  return haikuStandardPath(B_USER_SETTINGS_DIRECTORY);
162  default:
163  return QString();
164  }
165 }
166 
168 {
170 
171  const QString writablePath = writableLocation(type);
172  if (!writablePath.isEmpty())
173  paths += writablePath;
174 
175  switch (type) {
176  case DocumentsLocation: // fall through
177  case PicturesLocation:
178  case MusicLocation:
179  case MoviesLocation:
180  case DownloadLocation:
181  case HomeLocation:
182  paths += haikuStandardPath(B_USER_NONPACKAGED_DIRECTORY);
183  break;
184  case FontsLocation:
185  paths += haikuStandardPaths(B_FIND_PATH_FONTS_DIRECTORY);
186  break;
188  paths += haikuStandardPaths(B_FIND_PATH_BIN_DIRECTORY);
189  paths += haikuStandardPaths(B_FIND_PATH_APPS_DIRECTORY);
190  break;
191  case AppDataLocation: // fall through
193  paths += haikuAppStandardPaths(B_FIND_PATH_DATA_DIRECTORY);
194  break;
195  case GenericDataLocation:
196  paths += haikuStandardPaths(B_FIND_PATH_DATA_DIRECTORY);
197  break;
198  case CacheLocation:
199  paths += haikuAppStandardPath(B_SYSTEM_CACHE_DIRECTORY);
200  break;
202  paths += haikuStandardPath(B_SYSTEM_CACHE_DIRECTORY);
203  break;
204  case ConfigLocation: // fall through
205  case AppConfigLocation:
206  paths += haikuAppStandardPath(B_SYSTEM_SETTINGS_DIRECTORY);
207  break;
209  paths += haikuStandardPath(B_SYSTEM_SETTINGS_DIRECTORY);
210  break;
211  default:
212  break;
213  }
214 
215  return paths;
216 }
217 
219 
220 #endif // QT_NO_STANDARDPATHS
small capitals from c petite p scientific i
[1]
Definition: afcover.h:80
QString organizationName
the name of the organization that wrote this application
QString applicationName
the name of this application
static QString decodeName(const QByteArray &localFileName)
Definition: qfile.h:163
static QStringList standardLocations(StandardLocation type)
static QString writableLocation(StandardLocation type)
The QString class provides a Unicode character string.
Definition: qstring.h:388
bool isEmpty() const
Definition: qstring.h:1216
The QStringList class provides a list of strings.
QString haikuAppStandardPath(directory_which which)
QString haikuStandardPath(directory_which which)
void appendOrganizationAndApp(QString &path)
QStringList haikuStandardPaths(path_base_directory baseDirectory)
QStringList haikuAppStandardPaths(path_base_directory baseDirectory)
#define QString()
Definition: parse-defines.h:51
QList< QString > QStringList
Definition: qcontainerfwd.h:64
GLenum type
Definition: qopengl.h:270
GLsizei const GLuint * paths
GLsizei const GLchar *const * path
Definition: qopenglext.h:4283
Q_UNUSED(salary)
[21]
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:53