GH-2026 implement changes necessary to support 1.13 snapshots

This commit is contained in:
Petr Mrázek
2017-11-11 01:38:31 +01:00
parent 17c8f31a09
commit 85ae710d40
51 changed files with 2632 additions and 1058 deletions

View File

@ -14,38 +14,6 @@ namespace ProfileUtils
static const int currentOrderFileVersion = 1;
bool writeOverrideOrders(QString path, const PatchOrder &order)
{
QJsonObject obj;
obj.insert("version", currentOrderFileVersion);
QJsonArray orderArray;
for(auto str: order)
{
orderArray.append(str);
}
obj.insert("order", orderArray);
QSaveFile orderFile(path);
if (!orderFile.open(QFile::WriteOnly))
{
qCritical() << "Couldn't open" << orderFile.fileName()
<< "for writing:" << orderFile.errorString();
return false;
}
auto data = QJsonDocument(obj).toJson(QJsonDocument::Indented);
if(orderFile.write(data) != data.size())
{
qCritical() << "Couldn't write all the data into" << orderFile.fileName()
<< "because:" << orderFile.errorString();
return false;
}
if(!orderFile.commit())
{
qCritical() << "Couldn't save" << orderFile.fileName()
<< "because:" << orderFile.errorString();
}
return true;
}
bool readOverrideOrders(QString path, PatchOrder &order)
{
QFile orderFile(path);
@ -154,6 +122,25 @@ VersionFilePtr parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder)
return guardedParseJson(doc, fileInfo.completeBaseName(), fileInfo.absoluteFilePath(), requireOrder);
}
bool saveJsonFile(const QJsonDocument doc, const QString & filename)
{
auto data = doc.toJson();
QSaveFile jsonFile(filename);
if(!jsonFile.open(QIODevice::WriteOnly))
{
jsonFile.cancelWriting();
qWarning() << "Couldn't open" << filename << "for writing";
return false;
}
jsonFile.write(data);
if(!jsonFile.commit())
{
qWarning() << "Couldn't save" << filename;
return false;
}
return true;
}
VersionFilePtr parseBinaryJsonFile(const QFileInfo &fileInfo)
{
QFile file(fileInfo.absoluteFilePath());