Lock down the version cache. Just enough to make it annoying to corrupt the files.

This commit is contained in:
Petr Mrázek
2014-05-13 23:57:34 +02:00
parent f3900f2966
commit 55a0d110b6
8 changed files with 99 additions and 46 deletions

View File

@ -237,6 +237,25 @@ VersionFilePtr VersionBuilder::parseJsonFile(const QFileInfo &fileInfo, const bo
// info.").arg(file.fileName());
}
VersionFilePtr VersionBuilder::parseBinaryJsonFile(const QFileInfo &fileInfo)
{
QFile file(fileInfo.absoluteFilePath());
if (!file.open(QFile::ReadOnly))
{
throw JSONValidationError(QObject::tr("Unable to open the version file %1: %2.")
.arg(fileInfo.fileName(), file.errorString()));
}
QJsonDocument doc = QJsonDocument::fromBinaryData(file.readAll());
file.close();
if (doc.isNull())
{
file.remove();
throw JSONValidationError(
QObject::tr("Unable to process the version file %1.").arg(fileInfo.fileName()));
}
return VersionFile::fromJson(doc, file.fileName(), false, false);
}
QMap<QString, int> VersionBuilder::readOverrideOrders(OneSixInstance *instance)
{
QMap<QString, int> out;