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

Method processAsZip

launcher/minecraft/mod/LocalModParseTask.cpp:323–422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321}
322
323void LocalModParseTask::processAsZip()
324{
325 QuaZip zip(m_modFile.filePath());
326 if (!zip.open(QuaZip::mdUnzip))
327 return;
328
329 QuaZipFile file(&zip);
330
331 if (zip.setCurrentFile("META-INF/mods.toml"))
332 {
333 if (!file.open(QIODevice::ReadOnly))
334 {
335 zip.close();
336 return;
337 }
338
339 m_result->details = ReadMCModTOML(file.readAll());
340 file.close();
341
342 // to replace ${file.jarVersion} with the actual version, as needed
343 if (m_result->details && m_result->details->version == "${file.jarVersion}")
344 {
345 if (zip.setCurrentFile("META-INF/MANIFEST.MF"))
346 {
347 if (!file.open(QIODevice::ReadOnly))
348 {
349 zip.close();
350 return;
351 }
352
353 // quick and dirty line-by-line parser
354 auto manifestLines = file.readAll().split('\n');
355 QString manifestVersion = "";
356 for (auto &line : manifestLines)
357 {
358 if (QString(line).startsWith("Implementation-Version: "))
359 {
360 manifestVersion = QString(line).remove("Implementation-Version: ");
361 break;
362 }
363 }
364
365 // some mods use ${projectversion} in their build.gradle, causing this mess to show up in MANIFEST.MF
366 // also keep with forge's behavior of setting the version to "NONE" if none is found
367 if (manifestVersion.contains("task ':jar' property 'archiveVersion'") || manifestVersion == "")
368 {
369 manifestVersion = "NONE";
370 }
371
372 m_result->details->version = manifestVersion;
373
374 file.close();
375 }
376 }
377
378 zip.close();
379 return;
380 }

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected