diff options
author | flow <flowlnlnln@gmail.com> | 2022-05-16 10:50:46 -0300 |
---|---|---|
committer | flow <flowlnlnln@gmail.com> | 2022-05-16 12:11:50 -0300 |
commit | 82760f4b916ef122eabb644e8679f9ae76587e44 (patch) | |
tree | c31a6ce34d74c4dc878ddff4362152cdb5c80811 | |
parent | 62e099ace5db8e04bba684e6c2517291dcce3578 (diff) | |
download | PrismLauncher-82760f4b916ef122eabb644e8679f9ae76587e44.tar.gz PrismLauncher-82760f4b916ef122eabb644e8679f9ae76587e44.tar.bz2 PrismLauncher-82760f4b916ef122eabb644e8679f9ae76587e44.zip |
fix: import modrinth packs with weird overrides structure
Probably because of Packwiz limitations, or an space optimizer that did
this :)
-rw-r--r-- | launcher/MMCZip.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/launcher/MMCZip.cpp b/launcher/MMCZip.cpp index b92f1781..8591fcc0 100644 --- a/launcher/MMCZip.cpp +++ b/launcher/MMCZip.cpp @@ -297,20 +297,40 @@ nonstd::optional<QStringList> MMCZip::extractSubDir(QuaZip *zip, const QString & { continue; } + name.remove(0, subdir.size()); - QString absFilePath = directory.absoluteFilePath(name); + auto original_name = name; + + // Fix weird "folders with a single file get squashed" thing + QString path; + if(name.contains('/') && !name.endsWith('/')){ + path = name.section('/', 0, -2) + "/"; + FS::ensureFolderPathExists(path); + + name = name.split('/').last(); + } + + QString absFilePath; if(name.isEmpty()) { - absFilePath += "/"; + absFilePath = directory.absoluteFilePath(name) + "/"; } + else + { + absFilePath = directory.absoluteFilePath(path + name); + } + if (!JlCompress::extractFile(zip, "", absFilePath)) { - qWarning() << "Failed to extract file" << name << "to" << absFilePath; + qWarning() << "Failed to extract file" << original_name << "to" << absFilePath; JlCompress::removeFile(extracted); return nonstd::nullopt; } + extracted.append(absFilePath); - qDebug() << "Extracted file" << name; + QFile::setPermissions(absFilePath, QFileDevice::Permission::ReadUser | QFileDevice::Permission::WriteUser | QFileDevice::Permission::ExeUser); + + qDebug() << "Extracted file" << name << "to" << absFilePath; } while (zip->goToNextFile()); return extracted; } |