diff options
author | Petr Mrázek <peterix@gmail.com> | 2015-06-03 21:10:28 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2015-06-06 21:23:05 +0200 |
commit | 06a67fbd3852cdaa9bb4d8e2900543b47360f0fc (patch) | |
tree | c0f5e05661c1c31ae9815a8543157d45167100e3 /logic/BaseConfigObject.cpp | |
parent | 3a8b238052163952831fb5924b2483a375e86ebd (diff) | |
download | MultiMC-06a67fbd3852cdaa9bb4d8e2900543b47360f0fc.tar MultiMC-06a67fbd3852cdaa9bb4d8e2900543b47360f0fc.tar.gz MultiMC-06a67fbd3852cdaa9bb4d8e2900543b47360f0fc.tar.lz MultiMC-06a67fbd3852cdaa9bb4d8e2900543b47360f0fc.tar.xz MultiMC-06a67fbd3852cdaa9bb4d8e2900543b47360f0fc.zip |
NOISSUE use FS a bit more
Diffstat (limited to 'logic/BaseConfigObject.cpp')
-rw-r--r-- | logic/BaseConfigObject.cpp | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/logic/BaseConfigObject.cpp b/logic/BaseConfigObject.cpp index ff698ad0..3040ac2e 100644 --- a/logic/BaseConfigObject.cpp +++ b/logic/BaseConfigObject.cpp @@ -16,12 +16,12 @@ #include "BaseConfigObject.h" #include <QTimer> -#include <QSaveFile> #include <QFile> #include <QCoreApplication> #include <QDebug> #include "Exception.h" +#include "FileSystem.h" BaseConfigObject::BaseConfigObject(const QString &filename) : m_filename(filename) @@ -76,19 +76,13 @@ void BaseConfigObject::saveNow() return; } - QSaveFile file(m_filename); - if (!file.open(QFile::WriteOnly)) + try { - qWarning() << "Couldn't open" << m_filename << "for writing:" << file.errorString(); - return; + FS::write(m_filename, doSave()); } - // cppcheck-suppress pureVirtualCall - file.write(doSave()); - - if (!file.commit()) + catch (Exception & e) { - qCritical() << "Unable to commit the file" << file.fileName() << ":" << file.errorString(); - file.cancelWriting(); + qCritical() << e.cause(); } } void BaseConfigObject::loadNow() @@ -98,21 +92,11 @@ void BaseConfigObject::loadNow() saveNow(); } - QFile file(m_filename); - if (!file.exists()) - { - return; - } - if (!file.open(QFile::ReadOnly)) - { - qWarning() << "Couldn't open" << m_filename << "for reading:" << file.errorString(); - return; - } try { - doLoad(file.readAll()); + doLoad(FS::read(m_filename)); } - catch (Exception &e) + catch (Exception & e) { qWarning() << "Error loading" << m_filename << ":" << e.cause(); } |