diff options
author | Ken Moore <ken@ixsystems.com> | 2017-08-17 14:12:52 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2017-08-17 14:12:52 -0400 |
commit | 35ee744c9e937b82705a4350c6c07ca87dc4bca6 (patch) | |
tree | 304b77970d4c49e98bbeac2e0d9e526d2c676abf /src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp | |
parent | Merge branch 'master' of github.com:trueos/lumina (diff) | |
download | lumina-35ee744c9e937b82705a4350c6c07ca87dc4bca6.tar.gz lumina-35ee744c9e937b82705a4350c6c07ca87dc4bca6.tar.bz2 lumina-35ee744c9e937b82705a4350c6c07ca87dc4bca6.zip |
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.
Diffstat (limited to 'src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp')
-rw-r--r-- | src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
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 <QFile> #include <QDir> #include <QDebug> +#include <QDateTime> +#include <QCoreApplication> 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<paths.length(); i++){ - paths[i] = paths[i].section(parent,1,-1); + for(int i=0; i<paths.length(); i++){ + paths[i] = paths[i].section(parent,1,-1); if(paths[i].startsWith("/")){ paths[i].remove(0,1); } } args << "-C" << parent; args << paths; if(QFile::exists(filepath)){ //append to existing - args.replaceInStrings(filepath, tmpfilepath); + args.replaceInStrings(filepath, tmpfilepath); args<< "@"+filepath; } STARTING=true; @@ -151,11 +153,20 @@ void Backend::startExtract(QString path, bool overwrite, QStringList files){ void Backend::startViewFile(QString path){ QStringList args; + QString newfilename = QDateTime::currentDateTime().toString("yyyyMMddhhmmss")+"-"+path.section("/",-1); args << "-x"; - args << flags <<"--include" << path <<"--strip-components" << QString::number(path.count("/")) << "-C" << QDir::tempPath(); + //args << flags <<"--include" << path <<"--strip-components" << QString::number(path.count("/")) << "-C" << QDir::tempPath(); + args << flags <<"--include" << path <<"--to-stdout"; STARTING=true; //qDebug() << "Starting command:" << "tar" << args; - PROC.start("tar", args); + emit ProcessStarting(); + QProcess tmpProc; + tmpProc.setStandardOutputFile(newfilename); + tmpProc.start("tar",args); + while(!tmpProc.waitForFinished(500)){ QCoreApplication::processEvents(); } + emit ProcessFinished(tmpProc.exitCode()==0, ""); + QProcess::startDetached("xdg-open", QStringList() << newfilename); + //PROC.start("tar", args); } //=============== |