23#include <QApplication>
26#include <QStandardPaths>
27#include <QTemporaryDir>
42 qz_data_paths()->initCurrentProfile(profilePath);
50 const QString appDir = QCoreApplication::applicationDirPath();
52 d->m_paths[
AppData] = QStringList{appDir};
53 d->m_paths[
Config] = QStringList{appDir +
QSL(
"/config")};
54 d->m_paths[
Cache] = QStringList{appDir +
QSL(
"/cache")};
55 d->m_paths[
Profiles] = QStringList{appDir +
QSL(
"/config/profiles")};
57 d->m_paths[
Themes].clear();
59 d->initAssetsIn(appDir);
62 QDir().mkpath(d->m_paths[
Temp].at(0));
68 Q_ASSERT(!qz_data_paths()->m_paths[
path].isEmpty());
70 return qz_data_paths()->m_paths[
path].at(0);
76 Q_ASSERT(!qz_data_paths()->m_paths[type].isEmpty());
78 return qz_data_paths()->m_paths[type];
84 const QStringList dirs =
allPaths(type);
85 for (
const QString &dir : dirs) {
86 const QString fullPath = QDir(dir).absoluteFilePath(file);
87 if (QFileInfo::exists(fullPath)) {
100void DataPaths::init()
102 m_paths[
AppData].append(QStandardPaths::standardLocations(QStandardPaths::AppDataLocation));
104#ifdef FALKON_PLUGIN_PATH
105 m_paths[
Plugins].append(QStringLiteral(FALKON_PLUGIN_PATH));
108 for (
const QString &location : std::as_const(m_paths[
AppData])) {
109 initAssetsIn(location);
113 m_paths[
Config].append(QDir::tempPath() +
QSL(
"/Falkon-test"));
115 m_paths[
Config].append(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation));
118 m_paths[
Profiles].append(m_paths[
Config].at(0) + QLatin1String(
"/profiles"));
120 initAssetsIn(m_paths[
Config].at(0));
123 const QByteArray pluginPath = qgetenv(
"FALKON_PLUGIN_PATH");
124 if (!pluginPath.isNull()) {
125 m_paths[
Plugins] = QStringList{QString::fromLocal8Bit(pluginPath)};
128 m_tmpdir.reset(
new QTemporaryDir());
129 m_paths[
Temp].append(m_tmpdir->path());
130 if (!m_tmpdir->isValid()) {
131 qWarning() <<
"Failed to create temporary directory" << m_tmpdir->path();
134 m_paths[
Cache].append(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
137void DataPaths::initCurrentProfile(
const QString &profilePath)
141 if (m_paths[
Cache].isEmpty())
148 dir.mkpath(m_paths[
Cache].at(0));
149 dir.mkpath(m_paths[
Sessions].at(0));
152void DataPaths::initAssetsIn(
const QString &path)
154 m_paths[
Themes].append(
path + QLatin1String(
"/themes"));
155 m_paths[
Plugins].append(
path + QLatin1String(
"/plugins"));
static void setCurrentProfilePath(const QString &profilePath)
static void setPortableVersion()
static QString path(Path type)
static QStringList allPaths(Path type)
static QString currentProfilePath()
static QString locate(Path type, const QString &file)
static bool isTestModeEnabled()