| 321 | } |
| 322 | |
| 323 | void 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 | } |
nothing calls this directly
no test coverage detected