aboutsummaryrefslogtreecommitdiff
path: root/launcher/MMCZip.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/MMCZip.cpp')
-rw-r--r--launcher/MMCZip.cpp77
1 files changed, 46 insertions, 31 deletions
diff --git a/launcher/MMCZip.cpp b/launcher/MMCZip.cpp
index 0a334a83..cc749197 100644
--- a/launcher/MMCZip.cpp
+++ b/launcher/MMCZip.cpp
@@ -424,45 +424,60 @@ bool collectFileListRecursively(const QString& rootDir, const QString& subDir, Q
void ExportToZipTask::executeTask()
{
- (void)QtConcurrent::run(QThreadPool::globalInstance(), [this]() {
- setStatus("Adding files...");
- setProgress(0, m_files.length());
- if (!m_dir.exists()) {
- emitFailed(tr("Folder doesn't exist"));
+ (void)QtConcurrent::run(QThreadPool::globalInstance(), [this]() { exportZip(); });
+}
+
+void ExportToZipTask::exportZip()
+{
+ setStatus("Adding files...");
+ setProgress(0, m_files.length());
+ if (!m_dir.exists()) {
+ emitFailed(tr("Folder doesn't exist"));
+ return;
+ }
+ if (!m_output.isOpen() && !m_output.open(QuaZip::mdCreate)) {
+ emitFailed(tr("Could not create file"));
+ return;
+ }
+
+ for (auto fileName : m_extra_files.keys()) {
+ if (!isRunning())
return;
- }
- if (!m_output->isOpen() && !m_output->open(QuaZip::mdCreate)) {
- emitFailed(tr("Could not create file"));
+ QuaZipFile indexFile(&m_output);
+ if (!indexFile.open(QIODevice::WriteOnly, QuaZipNewInfo(fileName))) {
+ emitFailed(tr("Could not create:") + fileName);
return;
}
+ indexFile.write(m_extra_files[fileName]);
+ }
- for (const QFileInfo& file : m_files) {
- if (!isRunning())
- return;
-
- auto absolute = file.absoluteFilePath();
- auto relative = m_dir.relativeFilePath(absolute);
- setStatus("Compresing: " + relative);
- setProgress(m_progress + 1, m_progressTotal);
- if (m_followSymlinks) {
- if (file.isSymLink())
- absolute = file.symLinkTarget();
- else
- absolute = file.canonicalFilePath();
- }
+ for (const QFileInfo& file : m_files) {
+ if (!isRunning())
+ return;
- if (!JlCompress::compressFile(m_output.get(), absolute, m_destinationPrefix + relative)) {
- emitFailed(tr("Could not read and compress %1").arg(relative));
- return;
- }
+ auto absolute = file.absoluteFilePath();
+ auto relative = m_dir.relativeFilePath(absolute);
+ setStatus("Compresing: " + relative);
+ setProgress(m_progress + 1, m_progressTotal);
+ if (m_follow_symlinks) {
+ if (file.isSymLink())
+ absolute = file.symLinkTarget();
+ else
+ absolute = file.canonicalFilePath();
}
- m_output->close();
- if (m_output->getZipError() != 0) {
- emitFailed(tr("A zip error occurred"));
+ if (!m_exclude_files.contains(relative) && !JlCompress::compressFile(&m_output, absolute, m_destination_prefix + relative)) {
+ emitFailed(tr("Could not read and compress %1").arg(relative));
return;
}
- emitSucceeded();
- });
+ }
+
+ m_output.close();
+ if (m_output.getZipError() != 0) {
+ emitFailed(tr("A zip error occurred"));
+ return;
+ }
+ emitSucceeded();
}
+
} // namespace MMCZip \ No newline at end of file