mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-14 08:16:03 +02:00
Add PathUtils::generateTemporaryDir()
This commit is contained in:
parent
8e73eae341
commit
b862336d17
2 changed files with 16 additions and 0 deletions
|
@ -54,6 +54,19 @@ QString PathUtils::getAppLocalDataFilePath(const QString& filename) {
|
|||
return QDir(getAppLocalDataPath()).absoluteFilePath(filename);
|
||||
}
|
||||
|
||||
QString PathUtils::generateTemporaryDir() {
|
||||
QDir rootTempDir = QDir::tempPath();
|
||||
QString appName = qApp->applicationName();
|
||||
for (auto i = 0; i < 64; ++i) {
|
||||
auto now = std::chrono::system_clock::now().time_since_epoch().count();
|
||||
QDir tempDir = rootTempDir.filePath(appName + "-" + QString::number(now));
|
||||
if (tempDir.mkpath(".")) {
|
||||
return tempDir.absolutePath();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
QString fileNameWithoutExtension(const QString& fileName, const QVector<QString> possibleExtensions) {
|
||||
QString fileNameLowered = fileName.toLower();
|
||||
foreach (const QString possibleExtension, possibleExtensions) {
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtCore/QDir>
|
||||
|
||||
#include "DependencyManager.h"
|
||||
|
||||
|
@ -36,6 +37,8 @@ public:
|
|||
static QString getAppDataFilePath(const QString& filename);
|
||||
static QString getAppLocalDataFilePath(const QString& filename);
|
||||
|
||||
static QString generateTemporaryDir();
|
||||
|
||||
static Qt::CaseSensitivity getFSCaseSensitivity();
|
||||
static QString stripFilename(const QUrl& url);
|
||||
// note: this is FS-case-sensitive version of parentURL.isParentOf(childURL)
|
||||
|
|
Loading…
Reference in a new issue