2023-08-19 07:53:29 -04:00
|
|
|
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-08-18 14:52:06 -04:00
|
|
|
#include "utility.h"
|
|
|
|
|
|
|
|
#include <QStandardPaths>
|
|
|
|
|
|
|
|
QDir Utility::stateDirectory()
|
|
|
|
{
|
|
|
|
if (qEnvironmentVariableIsSet("XDG_STATE_HOME")) {
|
|
|
|
return qEnvironmentVariable("XDG_STATE_HOME");
|
|
|
|
}
|
|
|
|
|
|
|
|
const QDir homeDir = QStandardPaths::standardLocations(QStandardPaths::HomeLocation)[0];
|
2023-09-17 08:56:35 -04:00
|
|
|
const QDir localDir = homeDir.absoluteFilePath(QStringLiteral(".local"));
|
|
|
|
const QDir stateDir = localDir.absoluteFilePath(QStringLiteral("state"));
|
|
|
|
return stateDir.absoluteFilePath(QStringLiteral("astra"));
|
2023-08-18 14:52:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Utility::toWindowsPath(const QDir &dir)
|
|
|
|
{
|
2023-09-17 08:56:35 -04:00
|
|
|
return QStringLiteral("Z:") + dir.absolutePath().replace(QLatin1Char('/'), QLatin1Char('\\'));
|
2023-08-18 14:52:06 -04:00
|
|
|
}
|