MCPcopy Create free account
hub / github.com/MultiMC/Launcher / processAsZip

Method processAsZip

launcher/minecraft/mod/LocalModParseTask.cpp:368–481  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

366}
367
368void LocalModParseTask::processAsZip()
369{
370 QuaZip zip(m_modFile.filePath());
371 if (!zip.open(QuaZip::mdUnzip))
372 return;
373
374 QuaZipFile file(&zip);
375
376 if (zip.setCurrentFile("META-INF/mods.toml"))
377 {
378 if (!file.open(QIODevice::ReadOnly))
379 {
380 zip.close();
381 return;
382 }
383
384 m_result->details = ReadMCModTOML(file.readAll());
385 file.close();
386
387 // to replace ${file.jarVersion} with the actual version, as needed
388 if (m_result->details && m_result->details->version == "${file.jarVersion}")
389 {
390 if (zip.setCurrentFile("META-INF/MANIFEST.MF"))
391 {
392 if (!file.open(QIODevice::ReadOnly))
393 {
394 zip.close();
395 return;
396 }
397
398 // quick and dirty line-by-line parser
399 auto manifestLines = file.readAll().split('\n');
400 QString manifestVersion = "";
401 for (auto &line : manifestLines)
402 {
403 if (QString(line).startsWith("Implementation-Version: "))
404 {
405 manifestVersion = QString(line).remove("Implementation-Version: ");
406 break;
407 }
408 }
409
410 // some mods use ${projectversion} in their build.gradle, causing this mess to show up in MANIFEST.MF
411 // also keep with forge's behavior of setting the version to "NONE" if none is found
412 if (manifestVersion.contains("task ':jar' property 'archiveVersion'") || manifestVersion == "")
413 {
414 manifestVersion = "NONE";
415 }
416
417 m_result->details->version = manifestVersion;
418
419 file.close();
420 }
421 }
422
423 zip.close();
424 return;
425 }

Callers

nothing calls this directly

Calls 10

ReadMCModTOMLFunction · 0.85
QStringClass · 0.85
ReadMCModInfoFunction · 0.85
ReadFabricModInfoFunction · 0.85
ReadQuiltModInfoFunction · 0.85
ReadForgeInfoFunction · 0.85
filePathMethod · 0.80
openMethod · 0.80
removeMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected