fix: add support for QByteArray inifile
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
a0944dab7a
commit
1e82cb6a7c
@ -1,9 +1,9 @@
|
||||
#include "LocalModParseTask.h"
|
||||
|
||||
#include <qdcss.h>
|
||||
#include <quazip/quazip.h>
|
||||
#include <quazip/quazipfile.h>
|
||||
#include <toml++/toml.h>
|
||||
#include <qdcss.h>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
@ -369,12 +369,11 @@ ModDetails ReadQuiltModInfo(QByteArray contents)
|
||||
details.icon_file = icon.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return details;
|
||||
}
|
||||
|
||||
ModDetails ReadForgeInfo(QString fileName)
|
||||
ModDetails ReadForgeInfo(QByteArray contents)
|
||||
{
|
||||
ModDetails details;
|
||||
// Read the data
|
||||
@ -382,7 +381,7 @@ ModDetails ReadForgeInfo(QString fileName)
|
||||
details.mod_id = "Forge";
|
||||
details.homeurl = "http://www.minecraftforge.net/forum/";
|
||||
INIFile ini;
|
||||
if (!ini.loadFile(fileName))
|
||||
if (!ini.loadFile(contents))
|
||||
return details;
|
||||
|
||||
QString major = ini.get("forge.major.number", "0").toString();
|
||||
@ -554,7 +553,7 @@ bool processZIP(Mod& mod, ProcessingLevel level)
|
||||
return false;
|
||||
}
|
||||
|
||||
details = ReadForgeInfo(file.getFileName());
|
||||
details = ReadForgeInfo(file.readAll());
|
||||
file.close();
|
||||
zip.close();
|
||||
|
||||
|
@ -37,11 +37,12 @@
|
||||
#include "settings/INIFile.h"
|
||||
#include <FileSystem.h>
|
||||
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QStringList>
|
||||
#include <QSaveFile>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QSaveFile>
|
||||
#include <QStringList>
|
||||
#include <QTemporaryFile>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
@ -71,6 +72,7 @@ bool INIFile::saveFile(QString fileName)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QString unescape(QString orig)
|
||||
{
|
||||
QString out;
|
||||
@ -185,6 +187,19 @@ bool INIFile::loadFile(QString fileName)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool INIFile::loadFile(QByteArray data)
|
||||
{
|
||||
QTemporaryFile file;
|
||||
if (!file.open())
|
||||
return false;
|
||||
file.write(data);
|
||||
file.flush();
|
||||
file.close();
|
||||
auto loaded = loadFile(file.fileName());
|
||||
file.remove();
|
||||
return loaded;
|
||||
}
|
||||
|
||||
QVariant INIFile::get(QString key, QVariant def) const
|
||||
{
|
||||
if (!this->contains(key))
|
||||
|
@ -50,6 +50,7 @@ public:
|
||||
explicit INIFile();
|
||||
|
||||
bool loadFile(QString fileName);
|
||||
bool loadFile(QByteArray data);
|
||||
bool saveFile(QString fileName);
|
||||
|
||||
QVariant get(QString key, QVariant def) const;
|
||||
|
Loading…
Reference in New Issue
Block a user