MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / processZIP

Function processZIP

launcher/minecraft/mod/tasks/LocalModParseTask.cpp:469–600  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

467}
468
469bool processZIP(Mod& mod, [[maybe_unused]] ProcessingLevel level)
470{
471 ModDetails details;
472
473 QuaZip zip(mod.fileinfo().filePath());
474 if (!zip.open(QuaZip::mdUnzip))
475 return false;
476
477 QuaZipFile file(&zip);
478
479 if (zip.setCurrentFile("META-INF/mods.toml") || zip.setCurrentFile("META-INF/neoforge.mods.toml")) {
480 if (!file.open(QIODevice::ReadOnly)) {
481 zip.close();
482 return false;
483 }
484
485 details = ReadMCModTOML(file.readAll());
486 file.close();
487
488 // to replace ${file.jarVersion} with the actual version, as needed
489 if (details.version == "${file.jarVersion}") {
490 if (zip.setCurrentFile("META-INF/MANIFEST.MF")) {
491 if (!file.open(QIODevice::ReadOnly)) {
492 zip.close();
493 return false;
494 }
495
496 // quick and dirty line-by-line parser
497 auto manifestLines = QString(file.readAll()).split(newlineRegex);
498 QString manifestVersion = "";
499 for (auto& line : manifestLines) {
500 if (line.startsWith("Implementation-Version: ", Qt::CaseInsensitive)) {
501 manifestVersion = line.remove("Implementation-Version: ", Qt::CaseInsensitive);
502 break;
503 }
504 }
505
506 // some mods use ${projectversion} in their build.gradle, causing this mess to show up in MANIFEST.MF
507 // also keep with forge's behavior of setting the version to "NONE" if none is found
508 if (manifestVersion.contains("task ':jar' property 'archiveVersion'") || manifestVersion == "") {
509 manifestVersion = "NONE";
510 }
511
512 details.version = manifestVersion;
513
514 file.close();
515 }
516 }
517
518 zip.close();
519 mod.setDetails(details);
520
521 return true;
522 } else if (zip.setCurrentFile("mcmod.info")) {
523 if (!file.open(QIODevice::ReadOnly)) {
524 zip.close();
525 return false;
526 }

Callers 7

processFunction · 0.70
DataPackParseTestClass · 0.50
WorldSaveParseTestClass · 0.50
test_parse_ZIP2Method · 0.50
ShaderPackParseTestClass · 0.50

Calls 14

ReadMCModTOMLFunction · 0.85
QStringClass · 0.85
ReadMCModInfoFunction · 0.85
ReadQuiltModInfoFunction · 0.85
ReadFabricModInfoFunction · 0.85
ReadForgeInfoFunction · 0.85
ReadNilModInfoFunction · 0.85
filePathMethod · 0.80
fileinfoMethod · 0.80
openMethod · 0.80
closeMethod · 0.80
removeMethod · 0.45

Tested by 1

test_parse_ZIP2Method · 0.40