From 04fd7bcdb2b3c4906d0518393c1c8e7bea2e9332 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 1 Mar 2016 14:42:07 -0800 Subject: [PATCH] create the directory to hold account file if not present --- libraries/networking/src/AccountManager.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libraries/networking/src/AccountManager.cpp b/libraries/networking/src/AccountManager.cpp index d0838c4a8f..af30132b70 100644 --- a/libraries/networking/src/AccountManager.cpp +++ b/libraries/networking/src/AccountManager.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -115,8 +116,12 @@ void AccountManager::accountInfoBalanceChanged(qint64 newBalance) { emit balanceChanged(newBalance); } +QString accountFileDir() { + return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); +} + QString accountFilePath() { - return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/AccountInfo.bin"; + return accountFileDir() + "/AccountInfo.bin"; } QVariantMap accountMapFromFile(bool& success) { @@ -370,6 +375,11 @@ void AccountManager::passErrorToCallback(QNetworkReply* requestReply) { bool writeAccountMapToFile(const QVariantMap& accountMap) { // re-open the file and truncate it QFile accountFile { accountFilePath() }; + + // make sure the directory that will hold the account file exists + QDir accountFileDirectory { accountFileDir() }; + accountFileDirectory.mkpath("."); + if (accountFile.open(QIODevice::WriteOnly)) { QDataStream writeStream(&accountFile);