Commit 19adccc4 authored by Toni Asensi Esteve's avatar Toni Asensi Esteve
Browse files

Archives: Last steps to unify searches of 7z and 7za executables

Use the `find7zExecutable()` function on other parts of the source code.

Those changes are related to https://phabricator.kde.org/D28416 and https://phabricator.kde.org/D28417

Test plan: The one described in the task [Solve some bugs related to archives, remove some duplicated code](https://phabricator.kde.org/T12876).

Differential Revision: https://phabricator.kde.org/D28418
parent b6ae179b
......@@ -228,7 +228,7 @@ long KRarcHandler::arcFileCount(const QString& archive, const QString& type, con
lister << KrServices::fullPathName("unarj") << "l";
} else if (type == "rpm") lister << KrServices::fullPathName("rpm") << "--dump" << "-lpq";
else if (type == "deb") lister << KrServices::fullPathName("dpkg") << "-c";
else if (type == "7z") lister << KrServices::fullPathName("7z") << "-y" << "l";
else if (type == "7z") lister << find7zExecutable() << "-y" << "l";
else return 0L;
if (!password.isNull()) {
......@@ -316,7 +316,7 @@ bool KRarcHandler::unpack(QString archive, const QString& type, const QString& p
packer << KrServices::fullPathName("arj") << "-y" << "-v" << "x";
else
packer << KrServices::fullPathName("unarj") << "x";
} else if (type == "7z") packer << KrServices::fullPathName("7z") << "-y" << "x";
} else if (type == "7z") packer << find7zExecutable() << "-y" << "x";
else if (type == "rpm") {
// TODO use QTemporaryFile (setAutoRemove(false) when asynchrone)
cpioName = QDir::tempPath() + QStringLiteral("/contents.cpio");
......@@ -426,7 +426,7 @@ bool KRarcHandler::test(const QString& archive, const QString& type, const QStri
else if (type == "lha") packer << KrServices::fullPathName("lha") << "t";
else if (type == "arj") packer << KrServices::fullPathName(KrServices::cmdExist("arj") ? "arj" : "unarj") << "t";
else if (type == "cpio") packer << KrServices::fullPathName("cpio") << "--only-verify-crc" << "-tvF";
else if (type == "7z") packer << KrServices::fullPathName("7z") << "-y" << "t";
else if (type == "7z") packer << find7zExecutable() << "-y" << "t";
else return false;
if (!password.isNull()) {
......@@ -504,7 +504,7 @@ bool KRarcHandler::pack(QStringList fileNames, QString type, const QString& dest
} else if (type == "arj") {
packer << KrServices::fullPathName("arj") << "-r" << "-y" << "a";
} else if (type == "7z") {
packer << KrServices::fullPathName("7z") << "-y" << "a";
packer << find7zExecutable() << "-y" << "a";
} else return false;
QString password;
......@@ -705,7 +705,7 @@ void KRarcHandler::checkIf7zIsEncrypted(bool &encrypted, QString fileName)
Kr7zEncryptionChecker proc;
// TODO incorporate all this in Kr7zEncryptionChecker
proc << KrServices::fullPathName("7z") << "-y" << "t";
proc << find7zExecutable() << "-y" << "t";
proc << fileName;
proc.start();
proc.waitForFinished();
......
......@@ -59,13 +59,13 @@ public:
explicit KRarcHandler(QObject *parent = nullptr);
// return the number of files in the archive
static long arcFileCount(const QString& archive, const QString& type, const QString& password, KRarcObserver *observer);
long arcFileCount(const QString& archive, const QString& type, const QString& password, KRarcObserver *observer);
// unpack an archive to destination directory
static bool unpack(QString archive, const QString& type, const QString& password, const QString& dest, KRarcObserver *observer );
bool unpack(QString archive, const QString& type, const QString& password, const QString& dest, KRarcObserver *observer );
// pack an archive to destination directory
static bool pack(QStringList fileNames, QString type, const QString& dest, long count, QMap<QString, QString> extraProps, KRarcObserver *observer );
bool pack(QStringList fileNames, QString type, const QString& dest, long count, QMap<QString, QString> extraProps, KRarcObserver *observer );
// test an archive
static bool test(const QString& archive, const QString& type, const QString& password, KRarcObserver *observer, long count = 0L );
bool test(const QString& archive, const QString& type, const QString& password, KRarcObserver *observer, long count = 0L );
// returns `true` if the right unpacker exist in the system
static bool arcSupported(QString type);
// return the list of supported packers
......
......@@ -20,6 +20,7 @@
#include "packjob.h"
#include "krarchandler.h"
#include "../krglobal.h"
// QtCore
#include <QDir>
......@@ -64,7 +65,7 @@ void PackThread::slotStart()
QString save = QDir::currentPath();
QDir::setCurrent(arcDir);
bool result = KRarcHandler::pack(_fileNames, _type, arcFile, totalFiles, _packProperties, observer());
bool result = krArcMan.pack(_fileNames, _type, arcFile, totalFiles, _packProperties, observer());
QDir::setCurrent(save);
if (isExited())
......@@ -108,7 +109,7 @@ void TestArchiveThread::slotStart()
return;
// test the archive
if (!KRarcHandler::test(path, type, password, observer(), 0)) {
if (!krArcMan.test(path, type, password, observer(), 0)) {
sendError(KIO::ERR_NO_CONTENT, i18nc("%1=archive filename", "%1, test failed.", arcName));
return;
}
......@@ -150,7 +151,7 @@ void UnpackThread::slotStart()
setProgressTitle(i18n("Processed files"));
// unpack the files
bool result = KRarcHandler::unpack(path, type, password, localDest, observer());
bool result = krArcMan.unpack(path, type, password, localDest, observer());
if (isExited())
return;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment