summaryrefslogtreecommitdiffstats
path: root/logic/minecraft/World.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-09-13 04:21:26 +0200
committerPetr Mrázek <peterix@gmail.com>2015-09-13 04:21:26 +0200
commit8ef07ec6346a4f9c078184c9497e7c12f5b8c33d (patch)
treeddb81e3591825bd1cd5e080e1fcc4aede553d911 /logic/minecraft/World.cpp
parent2315f463a8e7713fc62027bb9540a22b240a0f78 (diff)
downloadMultiMC-8ef07ec6346a4f9c078184c9497e7c12f5b8c33d.tar
MultiMC-8ef07ec6346a4f9c078184c9497e7c12f5b8c33d.tar.gz
MultiMC-8ef07ec6346a4f9c078184c9497e7c12f5b8c33d.tar.lz
MultiMC-8ef07ec6346a4f9c078184c9497e7c12f5b8c33d.tar.xz
MultiMC-8ef07ec6346a4f9c078184c9497e7c12f5b8c33d.zip
GH-1227 allow structured world zip import and drag and drop out of MultiMC
Diffstat (limited to 'logic/minecraft/World.cpp')
-rw-r--r--logic/minecraft/World.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/logic/minecraft/World.cpp b/logic/minecraft/World.cpp
index 142839d2..bb99aa96 100644
--- a/logic/minecraft/World.cpp
+++ b/logic/minecraft/World.cpp
@@ -27,6 +27,7 @@
#include <tag_primitive.h>
#include <quazip.h>
#include <quazipfile.h>
+#include <quazipdir.h>
World::World(const QFileInfo &file)
{
@@ -76,9 +77,16 @@ void World::readFromZip(const QFileInfo &file)
{
return;
}
+ auto location = MMCZip::findFileInZip(&zip, "level.dat");
+ is_valid = !location.isEmpty();
+ if (!is_valid)
+ {
+ return;
+ }
+ m_containerOffsetPath = location;
QuaZipFile zippedFile(&zip);
// read the install profile
- is_valid = zip.setCurrentFile("level.dat");
+ is_valid = zip.setCurrentFile(location + "level.dat");
if (!is_valid)
{
return;
@@ -109,8 +117,12 @@ bool World::install(QString to)
}
if(m_containerFile.isFile())
{
- // FIXME: check if this is OK.
- return !MMCZip::extractDir(m_containerFile.absoluteFilePath(), finalPath).isEmpty();
+ QuaZip zip(m_containerFile.absoluteFilePath());
+ if (!zip.open(QuaZip::mdUnzip))
+ {
+ return false;
+ }
+ return !MMCZip::extractSubDir(&zip, m_containerOffsetPath, finalPath).isEmpty();
}
else if(m_containerFile.isDir())
{