@@ -1,73 +0,0 @@
|
||||
#include "launcherpaths.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
|
||||
namespace {
|
||||
|
||||
const QString kFolderName = QStringLiteral("galeonLauncher");
|
||||
|
||||
} // namespace
|
||||
|
||||
QString LauncherPaths::containerDir()
|
||||
{
|
||||
#if defined(Q_OS_WIN)
|
||||
return QDir::homePath() + QStringLiteral("/AppData/Roaming");
|
||||
#elif defined(Q_OS_MACOS)
|
||||
return QDir::homePath() + QStringLiteral("/Library/Application Support");
|
||||
#else // Linux и прочие Unix-системы
|
||||
return QDir::homePath();
|
||||
#endif
|
||||
}
|
||||
|
||||
QString LauncherPaths::rootDir()
|
||||
{
|
||||
return containerDir() + u'/' + kFolderName;
|
||||
}
|
||||
|
||||
QString LauncherPaths::defaultMinecraftDir()
|
||||
{
|
||||
#if defined(Q_OS_MACOS)
|
||||
// На macOS папка игры исторически без точки.
|
||||
return containerDir() + QStringLiteral("/minecraft");
|
||||
#else
|
||||
return containerDir() + QStringLiteral("/.minecraft");
|
||||
#endif
|
||||
}
|
||||
|
||||
QString LauncherPaths::settingsFile()
|
||||
{
|
||||
return rootDir() + QStringLiteral("/settings.json");
|
||||
}
|
||||
|
||||
QString LauncherPaths::profilesFile()
|
||||
{
|
||||
return rootDir() + QStringLiteral("/profiles.json");
|
||||
}
|
||||
|
||||
QString LauncherPaths::versionsFile()
|
||||
{
|
||||
return rootDir() + QStringLiteral("/versions.json");
|
||||
}
|
||||
|
||||
QString LauncherPaths::runtimeDir()
|
||||
{
|
||||
return rootDir() + QStringLiteral("/runtime");
|
||||
}
|
||||
|
||||
bool LauncherPaths::ensureRootExists(QString *error)
|
||||
{
|
||||
const QStringList required{rootDir(), runtimeDir()};
|
||||
for (const QString &path : required) {
|
||||
if (QDir().mkpath(path))
|
||||
continue;
|
||||
|
||||
if (error) {
|
||||
*error = QCoreApplication::translate("LauncherPaths",
|
||||
"не удалось создать %1")
|
||||
.arg(QDir::toNativeSeparators(path));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user