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

Method mergeZipFiles

launcher/MMCZip.cpp:46–95  ·  view source on GitHub ↗

ours

Source from the content-addressed store, hash-verified

44
45// ours
46bool MMCZip::mergeZipFiles(QuaZip *into, QFileInfo from, QSet<QString> &contained, const FilterFunction filter)
47{
48 QuaZip modZip(from.filePath());
49 modZip.open(QuaZip::mdUnzip);
50
51 QuaZipFile fileInsideMod(&modZip);
52 QuaZipFile zipOutFile(into);
53 for (bool more = modZip.goToFirstFile(); more; more = modZip.goToNextFile())
54 {
55 QString filename = modZip.getCurrentFileName();
56 if (filter && !filter(filename))
57 {
58 qDebug() << "Skipping file " << filename << " from "
59 << from.fileName() << " - filtered";
60 continue;
61 }
62 if (contained.contains(filename))
63 {
64 qDebug() << "Skipping already contained file " << filename << " from "
65 << from.fileName();
66 continue;
67 }
68 contained.insert(filename);
69
70 if (!fileInsideMod.open(QIODevice::ReadOnly))
71 {
72 qCritical() << "Failed to open " << filename << " from " << from.fileName();
73 return false;
74 }
75
76 QuaZipNewInfo info_out(fileInsideMod.getActualFileName());
77
78 if (!zipOutFile.open(QIODevice::WriteOnly, info_out))
79 {
80 qCritical() << "Failed to open " << filename << " in the jar";
81 fileInsideMod.close();
82 return false;
83 }
84 if (!JlCompress::copyData(fileInsideMod, zipOutFile))
85 {
86 zipOutFile.close();
87 fileInsideMod.close();
88 qCritical() << "Failed to copy data of " << filename << " into the jar";
89 return false;
90 }
91 zipOutFile.close();
92 fileInsideMod.close();
93 }
94 return true;
95}
96
97bool MMCZip::compressDirFiles(QuaZip *zip, QString dir, QFileInfoList files)
98{

Callers

nothing calls this directly

Calls 4

filePathMethod · 0.80
openMethod · 0.80
insertMethod · 0.80
containsMethod · 0.45

Tested by

no test coverage detected