summaryrefslogtreecommitdiffstats
path: root/depends/settings
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-08-27 22:32:41 +0200
committerPetr Mrázek <peterix@gmail.com>2013-08-27 22:32:41 +0200
commitfcd05ca2f6b7a76063c98e2720be758be1f67980 (patch)
tree29638132d6f5365a6db0ec0d42a3d3ff1caf9c3e /depends/settings
parenta266e5d0ccafe1585bafd471d7a71181358ceb59 (diff)
downloadMultiMC-fcd05ca2f6b7a76063c98e2720be758be1f67980.tar
MultiMC-fcd05ca2f6b7a76063c98e2720be758be1f67980.tar.gz
MultiMC-fcd05ca2f6b7a76063c98e2720be758be1f67980.tar.lz
MultiMC-fcd05ca2f6b7a76063c98e2720be758be1f67980.tar.xz
MultiMC-fcd05ca2f6b7a76063c98e2720be758be1f67980.zip
Read mod files to get versions... and stuff.
Diffstat (limited to 'depends/settings')
-rw-r--r--depends/settings/include/inifile.h3
-rw-r--r--depends/settings/src/inifile.cpp12
2 files changed, 11 insertions, 4 deletions
diff --git a/depends/settings/include/inifile.h b/depends/settings/include/inifile.h
index e3ff6b64..8d30a258 100644
--- a/depends/settings/include/inifile.h
+++ b/depends/settings/include/inifile.h
@@ -16,7 +16,7 @@
#pragma once
#include <QString>
#include <QVariant>
-
+#include <QIODevice>
#include "libsettings_config.h"
@@ -26,6 +26,7 @@ class LIBSETTINGS_EXPORT INIFile : public QMap<QString, QVariant>
public:
explicit INIFile();
+ bool loadFile(QByteArray file);
bool loadFile(QString fileName);
bool saveFile(QString fileName);
diff --git a/depends/settings/src/inifile.cpp b/depends/settings/src/inifile.cpp
index b3ee3a90..1eae5609 100644
--- a/depends/settings/src/inifile.cpp
+++ b/depends/settings/src/inifile.cpp
@@ -60,10 +60,16 @@ bool INIFile::saveFile(QString fileName)
bool INIFile::loadFile(QString fileName)
{
- // TODO Handle errors.
QFile file(fileName);
- file.open(QIODevice::ReadOnly);
- QTextStream in(&file);
+ if(!file.open(QIODevice::ReadOnly))
+ return false;
+ bool success = loadFile(file.readAll());
+ file.close();
+ return success;
+}
+bool INIFile::loadFile( QByteArray file )
+{
+ QTextStream in(file);
in.setCodec("UTF-8");
QStringList lines = in.readAll().split('\n');