From 2ac43a4a79517b1a89115c634f4ae161392c27f4 Mon Sep 17 00:00:00 2001 From: sawinglogz <3787776-sawinglogz@users.noreply.gitlab.com> Date: Fri, 24 Apr 2020 16:58:10 -0400 Subject: [PATCH] Fix zipping on Windows. --- oscar/mainwindow.cpp | 6 ++++-- oscar/zip.cpp | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/oscar/mainwindow.cpp b/oscar/mainwindow.cpp index 4c0baea5..90f46a18 100644 --- a/oscar/mainwindow.cpp +++ b/oscar/mainwindow.cpp @@ -2702,6 +2702,7 @@ void MainWindow::on_actionCreate_Card_zip_triggered() for (auto & datacard : datacards) { QString cardPath = QDir(datacard.path).canonicalPath(); QString filename; + QString prefix; // Loop until a valid folder is selected or the user cancels. Disallow the SD card itself! while (true) { @@ -2715,6 +2716,7 @@ void MainWindow::on_actionCreate_Card_zip_triggered() } else { infostr = datacard.loader->loaderName(); } + prefix = infostr; folder += QDir::separator() + infostr + ".zip"; filename = QFileDialog::getSaveFileName(this, tr("Choose where to save zip"), folder, tr("ZIP files (*.zip)")); @@ -2747,7 +2749,7 @@ void MainWindow::on_actionCreate_Card_zip_triggered() if (ok) { ProgressDialog * prog = new ProgressDialog(this); prog->setMessage(tr("Creating zip...")); - ok = z.AddDirectory(cardPath, prog); + ok = z.AddDirectory(cardPath, prefix, prog); z.Close(); } else { qWarning() << "Unable to open" << filename; @@ -2807,7 +2809,7 @@ void MainWindow::on_actionCreate_OSCAR_Data_zip_triggered() if (ok) { debugLog.write(ui->logText->toPlainText().toLocal8Bit().data()); debugLog.close(); - QString debugLogName = oscarData.dirName() + QDir::separator() + QFileInfo(debugLog).fileName(); + QString debugLogName = oscarData.dirName() + "/" + QFileInfo(debugLog).fileName(); ok = z.AddFile(debugLog.fileName(), debugLogName); if (!ok) { qWarning() << "Unable to add debug log to zip!"; diff --git a/oscar/zip.cpp b/oscar/zip.cpp index 645e8eac..60a439c8 100644 --- a/oscar/zip.cpp +++ b/oscar/zip.cpp @@ -136,7 +136,7 @@ bool ZipFile::AddFile(const QString & path, const QString & name) if (archive_name.isEmpty()) archive_name = fi.fileName(); if (fi.isDir()) { - archive_name += QDir::separator(); + archive_name += "/"; m_progress += 1; } else { // Open and read file into memory. @@ -184,7 +184,7 @@ bool FileQueue::AddDirectory(const QString & path, const QString & prefix) for (auto & fi : flist) { QString canonicalPath = fi.canonicalFilePath(); - QString relative_path = base + QDir::separator() + fi.fileName(); + QString relative_path = base + "/" + fi.fileName(); if (fi.isSymLink()) { qWarning() << "skipping symlink" << canonicalPath << fi.symLinkTarget(); } else if (fi.isDir()) {