MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / processAsZip

Method processAsZip

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

Source from the content-addressed store, hash-verified

290{}
291
292void LocalModParseTask::processAsZip()
293{
294 QuaZip zip(m_modFile.filePath());
295 if (!zip.open(QuaZip::mdUnzip))
296 return;
297
298 QuaZipFile file(&zip);
299
300 if (zip.setCurrentFile("META-INF/neoforge.mods.toml") || zip.setCurrentFile("META-INF/mods.toml")) {
301 if (!file.open(QIODevice::ReadOnly)) {
302 zip.close();
303 return;
304 }
305
306 m_result->details = ReadMCModTOML(file.readAll());
307 file.close();
308
309 // to replace ${file.jarVersion} with the actual version, as needed
310 if (m_result->details.version == "${file.jarVersion}") {
311 if (zip.setCurrentFile("META-INF/MANIFEST.MF")) {
312 if (!file.open(QIODevice::ReadOnly)) {
313 zip.close();
314 return;
315 }
316
317 // quick and dirty line-by-line parser
318 auto manifestLines = file.readAll().split('\n');
319 QString manifestVersion = "";
320 for (auto& line : manifestLines) {
321 if (QString(line).startsWith("Implementation-Version: ")) {
322 manifestVersion = QString(line).remove("Implementation-Version: ");
323 break;
324 }
325 }
326
327 // some mods use ${projectversion} in their build.gradle, causing this mess to show up in MANIFEST.MF
328 // also keep with forge's behavior of setting the version to "NONE" if none is found
329 if (manifestVersion.contains("task ':jar' property 'archiveVersion'") || manifestVersion == "") {
330 manifestVersion = "NONE";
331 }
332
333 m_result->details.version = manifestVersion;
334
335 file.close();
336 }
337 }
338
339 zip.close();
340 return;
341 } else if (zip.setCurrentFile("mcmod.info")) {
342 if (!file.open(QIODevice::ReadOnly)) {
343 zip.close();
344 return;
345 }
346
347 m_result->details = ReadMCModInfo(file.readAll());
348 file.close();
349 zip.close();

Callers

nothing calls this directly

Calls 10

ReadMCModTOMLFunction · 0.85
QStringClass · 0.85
ReadMCModInfoFunction · 0.85
ReadQuiltModInfoFunction · 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