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

Method processZipPack

launcher/InstanceImportTask.cpp:86–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86void InstanceImportTask::processZipPack()
87{
88 setStatus(tr("Extracting modpack"));
89 QDir extractDir(m_stagingPath);
90 qDebug() << "Attempting to create instance from" << m_archivePath;
91
92 // open the zip and find relevant files in it
93 m_packZip.reset(new QuaZip(m_archivePath));
94 if (!m_packZip->open(QuaZip::mdUnzip))
95 {
96 emitFailed(tr("Unable to open supplied modpack zip file."));
97 return;
98 }
99
100 QStringList blacklist = {"instance.cfg", "manifest.json"};
101 QString mmcFound = MMCZip::findFolderOfFileInZip(m_packZip.get(), "instance.cfg");
102 bool technicFound = QuaZipDir(m_packZip.get()).exists("/bin/modpack.jar") || QuaZipDir(m_packZip.get()).exists("/bin/version.json");
103 QString flameFound = MMCZip::findFolderOfFileInZip(m_packZip.get(), "manifest.json");
104 QString root;
105 if(!mmcFound.isNull())
106 {
107 // process as MultiMC instance/pack
108 qDebug() << "MultiMC:" << mmcFound;
109 root = mmcFound;
110 m_modpackType = ModpackType::MultiMC;
111 }
112 else if (technicFound)
113 {
114 // process as Technic pack
115 qDebug() << "Technic:" << technicFound;
116 extractDir.mkpath(".minecraft");
117 extractDir.cd(".minecraft");
118 m_modpackType = ModpackType::Technic;
119 }
120 else if(!flameFound.isNull())
121 {
122 // process as Flame pack
123 qDebug() << "Flame:" << flameFound;
124 root = flameFound;
125 m_modpackType = ModpackType::Flame;
126 }
127 if(m_modpackType == ModpackType::Unknown)
128 {
129 emitFailed(tr("Archive does not contain a recognized modpack type."));
130 return;
131 }
132
133 // make sure we extract just the pack
134 m_extractFuture = QtConcurrent::run(QThreadPool::globalInstance(), MMCZip::extractSubDir, m_packZip.get(), root, extractDir.absolutePath());
135 connect(&m_extractFutureWatcher, &QFutureWatcher<QStringList>::finished, this, &InstanceImportTask::extractFinished);
136 connect(&m_extractFutureWatcher, &QFutureWatcher<QStringList>::canceled, this, &InstanceImportTask::extractAborted);
137 m_extractFutureWatcher.setFuture(m_extractFuture);
138}
139
140void InstanceImportTask::extractFinished()
141{

Callers

nothing calls this directly

Calls 5

runFunction · 0.85
openMethod · 0.80
existsMethod · 0.80
resetMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected