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

Method exportZip

launcher/MMCZip.cpp:467–511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465}
466
467auto ExportToZipTask::exportZip() -> ZipResult
468{
469 if (!m_dir.exists()) {
470 return ZipResult(tr("Folder doesn't exist"));
471 }
472 if (!m_output.isOpen() && !m_output.open(QuaZip::mdCreate)) {
473 return ZipResult(tr("Could not create file"));
474 }
475
476 for (auto fileName : m_extra_files.keys()) {
477 if (m_build_zip_future.isCanceled())
478 return ZipResult();
479 QuaZipFile indexFile(&m_output);
480 if (!indexFile.open(QIODevice::WriteOnly, QuaZipNewInfo(fileName))) {
481 return ZipResult(tr("Could not create:") + fileName);
482 }
483 indexFile.write(m_extra_files[fileName]);
484 }
485
486 for (const QFileInfo& file : m_files) {
487 if (m_build_zip_future.isCanceled())
488 return ZipResult();
489
490 auto absolute = file.absoluteFilePath();
491 auto relative = m_dir.relativeFilePath(absolute);
492 setStatus("Compressing: " + relative);
493 setProgress(m_progress + 1, m_progressTotal);
494 if (m_follow_symlinks) {
495 if (file.isSymLink())
496 absolute = file.symLinkTarget();
497 else
498 absolute = file.canonicalFilePath();
499 }
500
501 if (!m_exclude_files.contains(relative) && !JlCompress::compressFile(&m_output, absolute, m_destination_prefix + relative)) {
502 return ZipResult(tr("Could not read and compress %1").arg(relative));
503 }
504 }
505
506 m_output.close();
507 if (m_output.getZipError() != 0) {
508 return ZipResult(tr("A zip error occurred"));
509 }
510 return ZipResult();
511}
512
513void ExportToZipTask::finish()
514{

Callers

nothing calls this directly

Calls 7

existsMethod · 0.80
openMethod · 0.80
canonicalFilePathMethod · 0.80
closeMethod · 0.80
writeMethod · 0.45
isSymLinkMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected