diff options
author | Jan Dalheimer <jan@dalheimer.de> | 2013-12-16 21:17:50 +0100 |
---|---|---|
committer | Jan Dalheimer <jan@dalheimer.de> | 2013-12-16 21:17:50 +0100 |
commit | 47bf7fff27665496bc4212bcaccc80350f665f97 (patch) | |
tree | 878fd220464c5280fcbe589d3ed738ce0306ab2a /logic/auth/MojangAccountList.cpp | |
parent | ae68adc3a536525990b0668703fd74eded8ccfde (diff) | |
parent | dff00a6d2abb84a93e48ff00dda16444550d859f (diff) | |
download | PrismLauncher-47bf7fff27665496bc4212bcaccc80350f665f97.tar.gz PrismLauncher-47bf7fff27665496bc4212bcaccc80350f665f97.tar.bz2 PrismLauncher-47bf7fff27665496bc4212bcaccc80350f665f97.zip |
Merge remote-tracking branch 'upstream/develop' into updater_tests
Conflicts:
mmc_updater/src/tests/CMakeLists.txt
Diffstat (limited to 'logic/auth/MojangAccountList.cpp')
-rw-r--r-- | logic/auth/MojangAccountList.cpp | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/logic/auth/MojangAccountList.cpp b/logic/auth/MojangAccountList.cpp index 33990662..70bc0cf2 100644 --- a/logic/auth/MojangAccountList.cpp +++ b/logic/auth/MojangAccountList.cpp @@ -27,6 +27,7 @@ #include "logger/QsLog.h" #include "logic/auth/MojangAccount.h" +#include <pathutils.h> #define ACCOUNT_LIST_FORMAT_VERSION 2 @@ -265,11 +266,6 @@ bool MojangAccountList::loadList(const QString &filePath) return false; } - if (!QDir::current().exists(path)) - { - QDir::current().mkpath(path); - } - QFile file(path); // Try to open the file and fail if we can't. @@ -351,9 +347,16 @@ bool MojangAccountList::saveList(const QString &filePath) return false; } - if (!QDir::current().exists(path)) + // make sure the parent folder exists + if(!ensureFilePathExists(path)) + return false; + + // make sure the file wasn't overwritten with a folder before (fixes a bug) + QFileInfo finfo(path); + if(finfo.isDir()) { - QDir::current().mkpath(path); + QDir badDir(path); + badDir.removeRecursively(); } QLOG_INFO() << "Writing account list to" << path; @@ -411,3 +414,13 @@ void MojangAccountList::setListFilePath(QString path, bool autosave) m_listFilePath = path; m_autosave = autosave; } + +bool MojangAccountList::anyAccountIsValid() +{ + for(auto account:m_accounts) + { + if(account->accountStatus() != NotVerified) + return true; + } + return false; +} |