From a4779d32b60c0e324f719bd25c76a94c0384ac2e Mon Sep 17 00:00:00 2001 From: robotbrain Date: Mon, 3 Mar 2014 17:22:23 -0500 Subject: [PATCH 1/5] Fix ftb locations on old windows... again. --- MultiMC.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MultiMC.cpp b/MultiMC.cpp index 598a3a807..595643f82 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -319,7 +319,7 @@ void MultiMC::initGlobalSettings() #ifdef Q_OS_LINUX QString ftbDefault = QDir::home().absoluteFilePath(".ftblauncher"); #elif defined(Q_OS_WIN32) - QString ftbDefault = PathCombine(QStandardPaths::writableLocation(QStandardPaths::DataLocation), "/ftblauncher"); + QString ftbDefault = PathCombine(qgetenv("APPDATA"), "ftblauncher"); #elif defined(Q_OS_MAC) QString ftbDefault = PathCombine(QDir::homePath(), "Library/Application Support/ftblauncher"); From 97ad7d287c8d99aae6e5f030e1d5669b36ee254b Mon Sep 17 00:00:00 2001 From: robotbrain Date: Wed, 5 Mar 2014 16:20:45 -0500 Subject: [PATCH 2/5] Use windows api to prevent encoding problems. --- MultiMC.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/MultiMC.cpp b/MultiMC.cpp index 595643f82..51fd84aca 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -38,6 +38,10 @@ #include "logger/QsLog.h" #include +#ifdef Q_OS_WIN32 +#include "windows.h" +#endif + using namespace Util::Commandline; MultiMC::MultiMC(int &argc, char **argv, bool root_override) @@ -319,7 +323,12 @@ void MultiMC::initGlobalSettings() #ifdef Q_OS_LINUX QString ftbDefault = QDir::home().absoluteFilePath(".ftblauncher"); #elif defined(Q_OS_WIN32) - QString ftbDefault = PathCombine(qgetenv("APPDATA"), "ftblauncher"); + wchar_t buf[1000]; + if(!GetEnvironmentVariableW(L"APPDATA", buf, 1000)) + { + QLOG_FATAL() << "Your APPDATA folder is missing! If you are on windows, this means your system is corrupt. If you aren't on windows, you have a problem."; + } + QString ftbDefault = PathCombine(QString::fromWCharArray(buf), "ftblauncher"); #elif defined(Q_OS_MAC) QString ftbDefault = PathCombine(QDir::homePath(), "Library/Application Support/ftblauncher"); From bb6894893d3da021ea0f2e30615fe9ed72502e5b Mon Sep 17 00:00:00 2001 From: robotbrain Date: Wed, 5 Mar 2014 16:27:18 -0500 Subject: [PATCH 3/5] Fix it - it did it even if the op failed. --- MultiMC.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/MultiMC.cpp b/MultiMC.cpp index 51fd84aca..ff4b186ae 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -1,4 +1,3 @@ - #include "MultiMC.h" #include #include @@ -324,11 +323,15 @@ void MultiMC::initGlobalSettings() QString ftbDefault = QDir::home().absoluteFilePath(".ftblauncher"); #elif defined(Q_OS_WIN32) wchar_t buf[1000]; + QString ftbDefault; if(!GetEnvironmentVariableW(L"APPDATA", buf, 1000)) { - QLOG_FATAL() << "Your APPDATA folder is missing! If you are on windows, this means your system is corrupt. If you aren't on windows, you have a problem."; + QLOG_FATAL() << "Your APPDATA folder is missing! If you are on windows, this means your system is broken. If you aren't on windows, how the **** are you running the windows build????"; + } + else + { + ftbDefault = PathCombine(QString::fromWCharArray(buf), "ftblauncher"); } - QString ftbDefault = PathCombine(QString::fromWCharArray(buf), "ftblauncher"); #elif defined(Q_OS_MAC) QString ftbDefault = PathCombine(QDir::homePath(), "Library/Application Support/ftblauncher"); From 6e964acde507640a3ce218cdd2393b1b49acd925 Mon Sep 17 00:00:00 2001 From: robotbrain Date: Wed, 5 Mar 2014 16:35:35 -0500 Subject: [PATCH 4/5] Use a constant for the buffer size. --- MultiMC.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/MultiMC.cpp b/MultiMC.cpp index ff4b186ae..6c5c4db68 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -38,7 +38,8 @@ #include #ifdef Q_OS_WIN32 -#include "windows.h" +#include +static const int APPDATA_BUFFER_SIZE = 1024; #endif using namespace Util::Commandline; @@ -322,9 +323,9 @@ void MultiMC::initGlobalSettings() #ifdef Q_OS_LINUX QString ftbDefault = QDir::home().absoluteFilePath(".ftblauncher"); #elif defined(Q_OS_WIN32) - wchar_t buf[1000]; + wchar_t buf[APPDATA_BUFFER_SIZE]; QString ftbDefault; - if(!GetEnvironmentVariableW(L"APPDATA", buf, 1000)) + if(!GetEnvironmentVariableW(L"APPDATA", buf, APPDATA_BUFFER_SIZE)) { QLOG_FATAL() << "Your APPDATA folder is missing! If you are on windows, this means your system is broken. If you aren't on windows, how the **** are you running the windows build????"; } From 96ee20072f4e20e279089c6b6e8de63d2da1f94e Mon Sep 17 00:00:00 2001 From: robotbrain Date: Fri, 7 Mar 2014 10:37:57 -0500 Subject: [PATCH 5/5] Add project files I use to gitignore. Its easier than opening a new pr for it. :P --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 2ef0d673f..d49ca85b7 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,8 @@ MultiMC5.kdev4 MultiMC.pro.user CMakeLists.txt.user CMakeLists.txt.user.* +/.project +/.settings # Build dirs build