diff options
Diffstat (limited to 'src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp')
-rw-r--r-- | src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp | 28 |
1 files changed, 20 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..e0b802a4 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); } //=============== @@ -251,6 +262,7 @@ void Backend::procFinished(int retcode, QProcess::ExitStatus){ } } if(args.contains("-x")){ result = tr("Extraction Finished"); emit ExtractSuccessful(); } + //if(args.contains("-aa")){ result = tr("Archival Finished"); emit ArchivalSuccessful(); } else if(args.contains("-c")){ result = tr("Modification Finished"); } if(needupdate){ startList(); } else{ emit ProcessFinished(retcode==0, result); result.clear(); } |