Overte C++ Documentation
PathUtils.h
1 //
2 // PathUtils.h
3 // libraries/shared/src
4 //
5 // Created by Brad Hefta-Gaub on 12/15/14.
6 // Copyright 2014 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_PathUtils_h
13 #define hifi_PathUtils_h
14 
15 #include <QtCore/QObject>
16 #include <QtCore/QUrl>
17 #include <QtCore/QDir>
18 
19 #include "DependencyManager.h"
20 
21 /*@jsdoc
22  * The <code>Paths</code> API provides absolute paths to the scripts and resources directories.
23  *
24  * @namespace Paths
25  *
26  * @hifi-interface
27  * @hifi-client-entity
28  * @hifi-avatar
29  *
30  * @deprecated The Paths API is deprecated. Use {@link Script.resolvePath} and {@link Script.resourcesPath} instead.
31  * @readonly
32  * @property {string} defaultScripts - The path to the scripts directory. <em>Read-only.</em>
33  * @property {string} resources - The path to the resources directory. <em>Read-only.</em>
34  */
35 class PathUtils : public QObject, public Dependency {
36  Q_OBJECT
37  SINGLETON_DEPENDENCY
38  Q_PROPERTY(QString resources READ resourcesPath CONSTANT)
39  Q_PROPERTY(QUrl defaultScripts READ defaultScriptsLocation CONSTANT)
40 public:
41  static const QString& getRccPath();
42  static const QString& resourcesUrl();
43  static QUrl resourcesUrl(const QString& relative);
44  static const QString& resourcesPath();
45  static const QString& qmlBaseUrl();
46  static QUrl expandToLocalDataAbsolutePath(const QUrl& fileUrl);
47  static QUrl qmlUrl(const QString& relative);
48 #ifdef DEV_BUILD
49  static const QString& projectRootPath();
50 #endif
51 
52  static QString getAppDataPath();
53  static QString getAppLocalDataPath();
54 
55  static QString getAppDataFilePath(const QString& filename);
56  static QString getAppLocalDataFilePath(const QString& filename);
57 
58  static QString generateTemporaryDir();
59  static bool deleteMyTemporaryDir(QString dirName);
60 
61  static int removeTemporaryApplicationDirs(QString appName = QString());
62 
63  static Qt::CaseSensitivity getFSCaseSensitivity();
64  static QString stripFilename(const QUrl& url);
65  // note: this is FS-case-sensitive version of parentURL.isParentOf(childURL)
66  static bool isDescendantOf(const QUrl& childURL, const QUrl& parentURL);
67  static QUrl defaultScriptsLocation(const QString& newDefault = "");
68 };
69 
70 QString fileNameWithoutExtension(const QString& fileName, const QVector<QString> possibleExtensions);
71 QString findMostRecentFileExtension(const QString& originalFileName, QVector<QString> possibleExtensions);
72 
73 #endif // hifi_PathUtils_h