From eea17de71ca7198bb3e463b730c534090496fc7c Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 18 Nov 2016 10:36:46 -0500 Subject: Add a couple new features to lumina-archiver: 1) Add the ability to extract only the selected item from an archive 2) Add better status reporting on archive interactions Changelog=yes --- .../desktop-utils/lumina-archiver/TarBackend.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp') diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp index 4dee247b..de3ef49b 100644 --- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp @@ -32,7 +32,7 @@ void Backend::loadFile(QString path){ flags.clear(); flags << "-f" << filepath; //add the actual archive path if(QFile::exists(path)){ startList(); } - else{ contents.clear(); emit ProcessFinished(); } + else{ contents.clear(); emit ProcessFinished(true, ""); } } bool Backend::canModify(){ @@ -115,11 +115,13 @@ void Backend::startRemove(QStringList paths){ PROC.start("tar", args); } -void Backend::startExtract(QString path, bool overwrite){ +void Backend::startExtract(QString path, bool overwrite, QString file){ QStringList args; args << "-x"; if(!overwrite){ args << "-k"; } - args << flags << "-C" << path; + args << flags; + if(!file.isEmpty()){ args << "--include" << file << "--strip-components" << QString::number(file.count("/")); } + args << "-C" << path; STARTING=true; //qDebug() << "Starting command:" << "tar" << args; PROC.start("tar", args); @@ -174,17 +176,19 @@ void Backend::startList(){ // PRIVATE SLOTS //=============== void Backend::procFinished(int retcode, QProcess::ExitStatus){ + static QString result; processData(); qDebug() << "Process Finished:" << PROC.arguments() << retcode; LIST = STARTING = false; if(PROC.arguments().contains("-tv")){ if(retcode!=0){ contents.clear(); } //could not read archive - emit ProcessFinished(); + emit ProcessFinished(true,result); + result.clear(); }else{ bool needupdate = true; QStringList args = PROC.arguments(); if(args.contains("-x") && retcode==0){ - needupdate=false; + needupdate=false; if(args.contains("--include")){ //Need to find the full path to the extracted file QString path = args.last() +"/"+ args[ args.indexOf("--include")+1].section("/",-1); @@ -201,8 +205,10 @@ void Backend::procFinished(int retcode, QProcess::ExitStatus){ QFile::remove(tmpfilepath); } } + if(args.contains("-x")){ result = tr("Extraction Finished"); } + else if(args.contains("-c")){ result = tr("Modification Finished"); } if(needupdate){ startList(); } - else{ emit ProcessFinished(); } + else{ emit ProcessFinished(retcode==0, result); result.clear(); } } } @@ -213,7 +219,9 @@ void Backend::processData(){ if(read.endsWith("\n")){ data.clear(); } else{ data = read.section("\n",-1); read = read.section("\n",0,-2); } QStringList lines = read.split("\n",QString::SkipEmptyParts); + QString info; if(LIST){ parseLines(lines); } + else if(!lines.isEmpty()){ info = lines.last(); } //qDebug() << lines; - emit ProgressUpdate(-1, ""); + emit ProgressUpdate(-1, info); } -- cgit From dfcd09c7824548001260bc18dcae711c50f63de3 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 18 Nov 2016 12:37:01 -0500 Subject: Fix up the detection of links within an archive - and show them appropriately within the UI --- .../desktop-utils/lumina-archiver/TarBackend.cpp | 25 +++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp') diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp index de3ef49b..919a6813 100644 --- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp @@ -75,6 +75,16 @@ bool Backend::isDir(QString file){ return contents.value(file)[0].startsWith("d"); } +bool Backend::isLink(QString file){ + if(!contents.contains(file)){ return false; } + return contents.value(file)[0].startsWith("l"); +} + +QString Backend::linkTo(QString file){ + if(!contents.contains(file)){ return ""; } + return contents.value(file)[2]; +} + //Modification routines void Backend::startAdd(QStringList paths){ //NOTE: All the "paths" have to have the same parent directory @@ -153,14 +163,23 @@ void Backend::parseLines(QStringList lines){ QString file = info[1]; QString perms = ""; if(file.endsWith("/")){ perms = "d"; file.chop(1); } - contents.insert(file, QStringList() << perms << "-1" ); //Save the [perms, size ] + contents.insert(file, QStringList() << perms << "-1" <<""); //Save the [perms, size, linkto ] } else if(info.length()<9){ continue; } //invalid line //TAR Archive parsing while(info.length()>9){ info[8] = info[8]+" "+info[9]; info.removeAt(9); } //Filename has spaces in it QString file = info[8]; if(file.endsWith("/")){ file.chop(1); } - contents.insert(file, QStringList() << info[0] << info[4] ); //Save the [perms, size ] + QString linkto; + //See if this file has the "link to" or "->" notation + if(file.contains(" -> ")){ linkto = file.section(" -> ",1,-1); file = file.section(" -> ",0,0); } + else if(file.contains(" link to ")){ + //Special case - alternate form of a link within a tar archive (not reflected in perms) + linkto = file.section(" link to ",1,-1); + file = file.section(" link to ",0,0); + if(info[0].startsWith("-")){ info[0].replace(0,1,"l"); } + } + contents.insert(file, QStringList() << info[0] << info[4] << linkto); //Save the [perms, size, linkto ] } } @@ -178,7 +197,7 @@ void Backend::startList(){ void Backend::procFinished(int retcode, QProcess::ExitStatus){ static QString result; processData(); - qDebug() << "Process Finished:" << PROC.arguments() << retcode; + //qDebug() << "Process Finished:" << PROC.arguments() << retcode; LIST = STARTING = false; if(PROC.arguments().contains("-tv")){ if(retcode!=0){ contents.clear(); } //could not read archive -- cgit From 151062b99e29e18dbc614bf66582f908c864a96a Mon Sep 17 00:00:00 2001 From: q5sys Date: Sun, 20 Nov 2016 01:50:36 -0500 Subject: Revert "search clear function on ESC press" This reverts commit b9840ef585385fece513e24e4cea193d35328dc0, reversing changes made to cb5524f6fd5186414c11339375bebd3b808b4857. --- .../desktop-utils/lumina-archiver/TarBackend.cpp | 47 +++++----------------- 1 file changed, 10 insertions(+), 37 deletions(-) (limited to 'src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp') diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp index 919a6813..4dee247b 100644 --- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp @@ -32,7 +32,7 @@ void Backend::loadFile(QString path){ flags.clear(); flags << "-f" << filepath; //add the actual archive path if(QFile::exists(path)){ startList(); } - else{ contents.clear(); emit ProcessFinished(true, ""); } + else{ contents.clear(); emit ProcessFinished(); } } bool Backend::canModify(){ @@ -75,16 +75,6 @@ bool Backend::isDir(QString file){ return contents.value(file)[0].startsWith("d"); } -bool Backend::isLink(QString file){ - if(!contents.contains(file)){ return false; } - return contents.value(file)[0].startsWith("l"); -} - -QString Backend::linkTo(QString file){ - if(!contents.contains(file)){ return ""; } - return contents.value(file)[2]; -} - //Modification routines void Backend::startAdd(QStringList paths){ //NOTE: All the "paths" have to have the same parent directory @@ -125,13 +115,11 @@ void Backend::startRemove(QStringList paths){ PROC.start("tar", args); } -void Backend::startExtract(QString path, bool overwrite, QString file){ +void Backend::startExtract(QString path, bool overwrite){ QStringList args; args << "-x"; if(!overwrite){ args << "-k"; } - args << flags; - if(!file.isEmpty()){ args << "--include" << file << "--strip-components" << QString::number(file.count("/")); } - args << "-C" << path; + args << flags << "-C" << path; STARTING=true; //qDebug() << "Starting command:" << "tar" << args; PROC.start("tar", args); @@ -163,23 +151,14 @@ void Backend::parseLines(QStringList lines){ QString file = info[1]; QString perms = ""; if(file.endsWith("/")){ perms = "d"; file.chop(1); } - contents.insert(file, QStringList() << perms << "-1" <<""); //Save the [perms, size, linkto ] + contents.insert(file, QStringList() << perms << "-1" ); //Save the [perms, size ] } else if(info.length()<9){ continue; } //invalid line //TAR Archive parsing while(info.length()>9){ info[8] = info[8]+" "+info[9]; info.removeAt(9); } //Filename has spaces in it QString file = info[8]; if(file.endsWith("/")){ file.chop(1); } - QString linkto; - //See if this file has the "link to" or "->" notation - if(file.contains(" -> ")){ linkto = file.section(" -> ",1,-1); file = file.section(" -> ",0,0); } - else if(file.contains(" link to ")){ - //Special case - alternate form of a link within a tar archive (not reflected in perms) - linkto = file.section(" link to ",1,-1); - file = file.section(" link to ",0,0); - if(info[0].startsWith("-")){ info[0].replace(0,1,"l"); } - } - contents.insert(file, QStringList() << info[0] << info[4] << linkto); //Save the [perms, size, linkto ] + contents.insert(file, QStringList() << info[0] << info[4] ); //Save the [perms, size ] } } @@ -195,19 +174,17 @@ void Backend::startList(){ // PRIVATE SLOTS //=============== void Backend::procFinished(int retcode, QProcess::ExitStatus){ - static QString result; processData(); - //qDebug() << "Process Finished:" << PROC.arguments() << retcode; + qDebug() << "Process Finished:" << PROC.arguments() << retcode; LIST = STARTING = false; if(PROC.arguments().contains("-tv")){ if(retcode!=0){ contents.clear(); } //could not read archive - emit ProcessFinished(true,result); - result.clear(); + emit ProcessFinished(); }else{ bool needupdate = true; QStringList args = PROC.arguments(); if(args.contains("-x") && retcode==0){ - needupdate=false; + needupdate=false; if(args.contains("--include")){ //Need to find the full path to the extracted file QString path = args.last() +"/"+ args[ args.indexOf("--include")+1].section("/",-1); @@ -224,10 +201,8 @@ void Backend::procFinished(int retcode, QProcess::ExitStatus){ QFile::remove(tmpfilepath); } } - if(args.contains("-x")){ result = tr("Extraction Finished"); } - else if(args.contains("-c")){ result = tr("Modification Finished"); } if(needupdate){ startList(); } - else{ emit ProcessFinished(retcode==0, result); result.clear(); } + else{ emit ProcessFinished(); } } } @@ -238,9 +213,7 @@ void Backend::processData(){ if(read.endsWith("\n")){ data.clear(); } else{ data = read.section("\n",-1); read = read.section("\n",0,-2); } QStringList lines = read.split("\n",QString::SkipEmptyParts); - QString info; if(LIST){ parseLines(lines); } - else if(!lines.isEmpty()){ info = lines.last(); } //qDebug() << lines; - emit ProgressUpdate(-1, info); + emit ProgressUpdate(-1, ""); } -- cgit From c79aa5623796f62aa67b2c37367e28710b0f05d2 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Sun, 20 Nov 2016 13:22:08 -0500 Subject: Revert "Revert "search clear function on ESC press"" This reverts commit 151062b99e29e18dbc614bf66582f908c864a96a. --- .../desktop-utils/lumina-archiver/TarBackend.cpp | 47 +++++++++++++++++----- 1 file changed, 37 insertions(+), 10 deletions(-) (limited to 'src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp') diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp index 4dee247b..919a6813 100644 --- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp @@ -32,7 +32,7 @@ void Backend::loadFile(QString path){ flags.clear(); flags << "-f" << filepath; //add the actual archive path if(QFile::exists(path)){ startList(); } - else{ contents.clear(); emit ProcessFinished(); } + else{ contents.clear(); emit ProcessFinished(true, ""); } } bool Backend::canModify(){ @@ -75,6 +75,16 @@ bool Backend::isDir(QString file){ return contents.value(file)[0].startsWith("d"); } +bool Backend::isLink(QString file){ + if(!contents.contains(file)){ return false; } + return contents.value(file)[0].startsWith("l"); +} + +QString Backend::linkTo(QString file){ + if(!contents.contains(file)){ return ""; } + return contents.value(file)[2]; +} + //Modification routines void Backend::startAdd(QStringList paths){ //NOTE: All the "paths" have to have the same parent directory @@ -115,11 +125,13 @@ void Backend::startRemove(QStringList paths){ PROC.start("tar", args); } -void Backend::startExtract(QString path, bool overwrite){ +void Backend::startExtract(QString path, bool overwrite, QString file){ QStringList args; args << "-x"; if(!overwrite){ args << "-k"; } - args << flags << "-C" << path; + args << flags; + if(!file.isEmpty()){ args << "--include" << file << "--strip-components" << QString::number(file.count("/")); } + args << "-C" << path; STARTING=true; //qDebug() << "Starting command:" << "tar" << args; PROC.start("tar", args); @@ -151,14 +163,23 @@ void Backend::parseLines(QStringList lines){ QString file = info[1]; QString perms = ""; if(file.endsWith("/")){ perms = "d"; file.chop(1); } - contents.insert(file, QStringList() << perms << "-1" ); //Save the [perms, size ] + contents.insert(file, QStringList() << perms << "-1" <<""); //Save the [perms, size, linkto ] } else if(info.length()<9){ continue; } //invalid line //TAR Archive parsing while(info.length()>9){ info[8] = info[8]+" "+info[9]; info.removeAt(9); } //Filename has spaces in it QString file = info[8]; if(file.endsWith("/")){ file.chop(1); } - contents.insert(file, QStringList() << info[0] << info[4] ); //Save the [perms, size ] + QString linkto; + //See if this file has the "link to" or "->" notation + if(file.contains(" -> ")){ linkto = file.section(" -> ",1,-1); file = file.section(" -> ",0,0); } + else if(file.contains(" link to ")){ + //Special case - alternate form of a link within a tar archive (not reflected in perms) + linkto = file.section(" link to ",1,-1); + file = file.section(" link to ",0,0); + if(info[0].startsWith("-")){ info[0].replace(0,1,"l"); } + } + contents.insert(file, QStringList() << info[0] << info[4] << linkto); //Save the [perms, size, linkto ] } } @@ -174,17 +195,19 @@ void Backend::startList(){ // PRIVATE SLOTS //=============== void Backend::procFinished(int retcode, QProcess::ExitStatus){ + static QString result; processData(); - qDebug() << "Process Finished:" << PROC.arguments() << retcode; + //qDebug() << "Process Finished:" << PROC.arguments() << retcode; LIST = STARTING = false; if(PROC.arguments().contains("-tv")){ if(retcode!=0){ contents.clear(); } //could not read archive - emit ProcessFinished(); + emit ProcessFinished(true,result); + result.clear(); }else{ bool needupdate = true; QStringList args = PROC.arguments(); if(args.contains("-x") && retcode==0){ - needupdate=false; + needupdate=false; if(args.contains("--include")){ //Need to find the full path to the extracted file QString path = args.last() +"/"+ args[ args.indexOf("--include")+1].section("/",-1); @@ -201,8 +224,10 @@ void Backend::procFinished(int retcode, QProcess::ExitStatus){ QFile::remove(tmpfilepath); } } + if(args.contains("-x")){ result = tr("Extraction Finished"); } + else if(args.contains("-c")){ result = tr("Modification Finished"); } if(needupdate){ startList(); } - else{ emit ProcessFinished(); } + else{ emit ProcessFinished(retcode==0, result); result.clear(); } } } @@ -213,7 +238,9 @@ void Backend::processData(){ if(read.endsWith("\n")){ data.clear(); } else{ data = read.section("\n",-1); read = read.section("\n",0,-2); } QStringList lines = read.split("\n",QString::SkipEmptyParts); + QString info; if(LIST){ parseLines(lines); } + else if(!lines.isEmpty()){ info = lines.last(); } //qDebug() << lines; - emit ProgressUpdate(-1, ""); + emit ProgressUpdate(-1, info); } -- cgit