control Prism data directory via env variable

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2024-06-29 18:08:28 +03:00
parent 196b2b5a3e
commit 7a0b299be9
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318
2 changed files with 16 additions and 1 deletions

View File

@ -292,12 +292,17 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
QString adjustedBy;
QString dataPath;
// change folder
QString dataDirEnv;
QString dirParam = parser.value("dir");
if (!dirParam.isEmpty()) {
// the dir param. it makes multimc data path point to whatever the user specified
// on command line
adjustedBy = "Command line";
dataPath = dirParam;
} else if (dataDirEnv = QProcessEnvironment::systemEnvironment().value(QString("%1_DATA_DIR").arg(BuildConfig.LAUNCHER_NAME.toUpper()));
!dataDirEnv.isEmpty()) {
adjustedBy = "System environment";
dataPath = dataDirEnv;
} else {
QDir foo;
if (DesktopServices::isSnap()) {
@ -443,7 +448,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
// search the dataPath()
// seach app data standard path
if (!foundLoggingRules && !isPortable() && dirParam.isEmpty()) {
if (!foundLoggingRules && !isPortable() && dirParam.isEmpty() && dataDirEnv.isEmpty()) {
logRulesPath = QStandardPaths::locate(QStandardPaths::AppDataLocation, FS::PathCombine("..", logRulesFile));
if (!logRulesPath.isEmpty()) {
qDebug() << "Found" << logRulesPath << "...";

View File

@ -331,6 +331,16 @@ PrismUpdaterApp::PrismUpdaterApp(int& argc, char** argv) : QApplication(argc, ar
if (QFile::exists(FS::PathCombine(m_rootPath, "portable.txt"))) {
m_isPortable = true;
}
#endif
} else if (auto dataDirEnv =
QProcessEnvironment::systemEnvironment().value(QString("%1_DATA_DIR").arg(BuildConfig.LAUNCHER_NAME.toUpper()));
!dataDirEnv.isEmpty()) {
adjustedBy = "System environment";
m_dataPath = dataDirEnv;
#ifndef Q_OS_MACOS
if (QFile::exists(FS::PathCombine(m_rootPath, "portable.txt"))) {
m_isPortable = true;
}
#endif
} else {
QDir foo(FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), ".."));