NOISSUE it's LOCALAPPDATA not APPDATALOCAL...

This commit is contained in:
Petr Mrázek 2022-05-29 00:17:01 +02:00
parent 8a6f673567
commit 43ebd02dcf

View File

@ -77,12 +77,13 @@ QString getFTBASettingsPath() {
#elif defined(Q_OS_WIN32) #elif defined(Q_OS_WIN32)
QString getFTBASettingsPath() { QString getFTBASettingsPath() {
wchar_t buf[BUFFER_SIZE]; wchar_t buf[BUFFER_SIZE];
if(!GetEnvironmentVariableW(L"APPDATALOCAL", buf, BUFFER_SIZE)) if(!GetEnvironmentVariableW(L"LOCALAPPDATA", buf, BUFFER_SIZE))
{ {
return QString(); return QString();
} }
QString appDataLocal = QString::fromWCharArray(buf); QString appDataLocal = QString::fromWCharArray(buf);
return FS::PathCombine(appDataLocal, ".ftba/bin/settings.json"); QString settingsPath = FS::PathCombine(appDataLocal, ".ftba/bin/settings.json");
return settingsPath;
} }
#else #else
QString getFTBASettingsPath() { QString getFTBASettingsPath() {
@ -92,14 +93,14 @@ QString getFTBASettingsPath() {
QString getFTBAInstances() { QString getFTBAInstances() {
QByteArray data; QByteArray data;
auto settingsPath = getFTBASettingsPath();
try try
{ {
auto path = getFTBASettingsPath(); data = FS::read(settingsPath);
data = FS::read(path);
} }
catch (const Exception &e) catch (const Exception &e)
{ {
qWarning() << "Could not read FTBA settings file"; qWarning() << "Could not read FTB App settings file: " << settingsPath;
return QString(); return QString();
} }
@ -111,13 +112,13 @@ QString getFTBAInstances() {
} }
catch (Json::JsonException & e) catch (Json::JsonException & e)
{ {
qCritical() << "Could not read FTBA settings file as JSON: " << e.cause(); qCritical() << "Could not read FTB App settings file as JSON: " << e.cause();
return QString(); return QString();
} }
} }
/* /*
Reference from an FTBA file, as of 28.05.2022 Reference from an FTB App file, as of 28.05.2022
{ {
"_private": false, "_private": false,
"uuid": "25850fc6-ec61-4bc6-8397-77e4497bf922", "uuid": "25850fc6-ec61-4bc6-8397-77e4497bf922",
@ -183,7 +184,7 @@ bool parseModpackJson(const QByteArray& data, Modpack & out) {
} }
catch (Json::JsonException & e) catch (Json::JsonException & e)
{ {
qCritical() << "Could not read FTBA settings file as JSON: " << e.cause(); qCritical() << "Could not read FTB App settings file as JSON: " << e.cause();
return false; return false;
} }
} }
@ -209,7 +210,7 @@ bool tryLoadInstance(const QString& location, Modpack & out) {
} }
catch (const Exception &e) catch (const Exception &e)
{ {
qWarning() << "Could not read FTBA instance JSON file: " << jsonLocation; qWarning() << "Could not read FTB App instance JSON file: " << jsonLocation;
return false; return false;
} }
return false; return false;