diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-05-13 23:57:34 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-06-09 01:38:31 +0200 |
commit | 55a0d110b654a93ef1bb9ee50a6f02ecaec7f88d (patch) | |
tree | 5957085e7e33d0b8f85859f421c1571b0ae6f978 /logic/minecraft/VersionBuilder.cpp | |
parent | f3900f2966e8c211fee51ece156da054df2d47c7 (diff) | |
download | MultiMC-55a0d110b654a93ef1bb9ee50a6f02ecaec7f88d.tar MultiMC-55a0d110b654a93ef1bb9ee50a6f02ecaec7f88d.tar.gz MultiMC-55a0d110b654a93ef1bb9ee50a6f02ecaec7f88d.tar.lz MultiMC-55a0d110b654a93ef1bb9ee50a6f02ecaec7f88d.tar.xz MultiMC-55a0d110b654a93ef1bb9ee50a6f02ecaec7f88d.zip |
Lock down the version cache. Just enough to make it annoying to corrupt the files.
Diffstat (limited to 'logic/minecraft/VersionBuilder.cpp')
-rw-r--r-- | logic/minecraft/VersionBuilder.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/logic/minecraft/VersionBuilder.cpp b/logic/minecraft/VersionBuilder.cpp index d19c2877..cff70821 100644 --- a/logic/minecraft/VersionBuilder.cpp +++ b/logic/minecraft/VersionBuilder.cpp @@ -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; |