From 35ee744c9e937b82705a4350c6c07ca87dc4bca6 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 17 Aug 2017 14:12:52 -0400 Subject: Change up the single-file extraction system in lumina-archiver: Now have it extract to a datetime-stamped filename in the temp directory, allowing for multiple files with the same name to be previewed at teh same time. --- src-qt5/desktop-utils/lumina-archiver/MainUI.cpp | 10 ++++++-- .../desktop-utils/lumina-archiver/TarBackend.cpp | 27 +++++++++++++++------- src-qt5/desktop-utils/lumina-archiver/TarBackend.h | 2 +- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp index 2dae90a4..afead9af 100644 --- a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp @@ -196,8 +196,8 @@ QString MainUI::OpenFileTypes(){ void MainUI::NewArchive(){ QString file = QFileDialog::getSaveFileName(this, tr("Create Archive"), QDir::homePath(), CreateFileTypes() ); if(file.isEmpty()){ return; } - if(QFile::exists(file)){ - if( !QFile::remove(file) ){ QMessageBox::warning(this, tr("Error"), QString(tr("Could not overwrite file:"))+"\n"+file); } + if(QFile::exists(file)){ + if( !QFile::remove(file) ){ QMessageBox::warning(this, tr("Error"), QString(tr("Could not overwrite file:"))+"\n"+file); } } ui->label_progress->setText(""); //just clear it (this action is instant) BACKEND->loadFile(file); @@ -267,6 +267,12 @@ void MainUI::extractSelection(){ void MainUI::ViewFile(QTreeWidgetItem *it){ if(it->childCount()>0){ return; } //directory - not viewable + /*QString newfile = QDir::tempPath()+"/"+it->whatsThis(0).section("/",-1); + if(QFile::exists(newfile)){ + if(QMessageBox::Yes != QMessageBox::question(this, tr("File exists"), tr("A temporary file with the same name already exists, do you want to overwrite it?")+"\n\n"+newfile, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ){ + return; //cancelled + } + }*/ ui->label_progress->setText(tr("Extracting...")); BACKEND->startViewFile(it->whatsThis(0)); } diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp index c0d3b03e..9fe735a3 100644 --- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp @@ -8,6 +8,8 @@ #include #include #include +#include +#include Backend::Backend(QObject *parent) : QObject(parent){ //Setup the backend process @@ -38,8 +40,8 @@ void Backend::loadFile(QString path){ } bool Backend::canModify(){ - static QStringList validEXT; - if( validEXT.isEmpty() ){ + static QStringList validEXT; + if( validEXT.isEmpty() ){ validEXT << ".zip" << ".tar.gz" << ".tgz" << ".tar.xz" << ".txz" << ".tar.bz" << ".tbz" << ".tar.bz2" << ".tbz2" << ".tar" \ << ".tar.lzma" << ".tlz" << ".cpio" << ".pax" << ".ar" << ".shar" << ".7z"; } @@ -95,16 +97,16 @@ void Backend::startAdd(QStringList paths){ QStringList args; args << "-c" << "-a"; args << flags; - //Now setup the parent dir + //Now setup the parent dir QString parent = paths[0].section("/",0,-2); - for(int i=0; i