diff --git a/krArc/krarc.h b/krArc/krarc.h --- a/krArc/krarc.h +++ b/krArc/krarc.h @@ -30,8 +30,6 @@ #include #include #include -#include -#include #include "krarcbasemanager.h" #include "krlinecountingprocess.h" @@ -97,7 +95,6 @@ KIO::UDSEntry* findFileEntry(const QUrl &url); /** add a new directory (file list container). */ KIO::UDSEntryList* addNewDir(const QString& path); - QString fullPathName(const QString& name); bool checkWriteSupport(); QHash dirDict; //< the directories data structure. @@ -113,8 +110,6 @@ QString arcType; //< the archive type. bool extArcReady; //< Used for RPM & DEB files. QString password; //< Password for the archives - KConfig krConf; //< The configuration file for krusader - KConfigGroup dependGrp; //< the 'Dependencies' config group QString lastData; QString encryptedArchPath; diff --git a/krArc/krarc.cpp b/krArc/krarc.cpp --- a/krArc/krarc.cpp +++ b/krArc/krarc.cpp @@ -147,11 +147,9 @@ #ifdef KRARC_ENABLED kio_krarcProtocol::kio_krarcProtocol(const QByteArray &pool_socket, const QByteArray &app_socket) : SlaveBase("kio_krarc", pool_socket, app_socket), archiveChanged(true), arcFile(nullptr), extArcReady(false), - password(QString()), krConf("krusaderrc"), codec(nullptr) + password(QString()), codec(nullptr) { KRFUNC; - dependGrp = KConfigGroup(&krConf, "Dependencies"); - KConfigGroup group(&krConf, "General"); QString tmpDirPath = group.readEntry("Temp Directory", _TempDirectory); QDir tmpDir(tmpDirPath); @@ -1853,29 +1851,6 @@ return password; } -QString kio_krarcProtocol::fullPathName(const QString& name) -{ - // Reminder: If that function is modified, it's important to research if the - // changes must also be applied to `KrServices::fullPathName()` - // and `KrServices::cmdExist()` - - // Note: KRFUNC was not used here in order to avoid filling the log with too much information - KRDEBUG(name); - - QString supposedName = dependGrp.readEntry(name, QString()); - if (QFileInfo::exists(supposedName)) - return supposedName; - - if ((supposedName = QStandardPaths::findExecutable(name)).isEmpty()) - return QString(); - - // Because an executable file has been found, its path is remembered - // in order to avoid some future searches - dependGrp.writeEntry(name, supposedName); - - return supposedName; -} - QString kio_krarcProtocol::localeEncodedString(QString str) { // Note: KRFUNC was not used here in order to avoid filling the log with too much information diff --git a/krArc/krarcbasemanager.h b/krArc/krarcbasemanager.h --- a/krArc/krarcbasemanager.h +++ b/krArc/krarcbasemanager.h @@ -22,6 +22,9 @@ #ifndef KRARCBASEMANAGER_H #define KRARCBASEMANAGER_H +#include +#include + // QtCore #include @@ -44,11 +47,18 @@ protected: //! The maximum length of a short QString that represents the type of a file static const int maxLenType; + //! The configuration file for Krusader + KConfig krConf; + //! The 'Dependencies' config group + KConfigGroup dependGrp; + + //! Search for the full path to a program + QString fullPathName(const QString& name); static bool checkStatus(const QString &, int); public: - KrArcBaseManager() {} + KrArcBaseManager(); QString detectArchive(bool &, const QString&, bool = true, bool = false); virtual void checkIf7zIsEncrypted(bool &, QString) = 0; static QString getShortTypeFromMime(const QString &); diff --git a/krArc/krarcbasemanager.cpp b/krArc/krarcbasemanager.cpp --- a/krArc/krarcbasemanager.cpp +++ b/krArc/krarcbasemanager.cpp @@ -20,9 +20,12 @@ *****************************************************************************/ #include "krarcbasemanager.h" +#include "../krusader/krdebuglogger.h" #include +#include + KrArcBaseManager::AutoDetectParams KrArcBaseManager::autoDetectParams[] = {{"zip", 0, "PK\x03\x04"}, {"rar", 0, "Rar!\x1a" }, {"arj", 0, "\x60\xea" }, @@ -38,6 +41,31 @@ int KrArcBaseManager::autoDetectElems = sizeof(autoDetectParams) / sizeof(AutoDetectParams); const int KrArcBaseManager::maxLenType = 5; +KrArcBaseManager::KrArcBaseManager() : krConf("krusaderrc"), dependGrp(&krConf, "Dependencies") {} + +QString KrArcBaseManager::fullPathName(const QString& name) +{ + // Reminder: If that function is modified, it's important to research if the + // changes must also be applied to `KrServices::fullPathName()` + // and `KrServices::cmdExist()` + + // Note: KRFUNC was not used here in order to avoid filling the log with too much information + KRDEBUG(name); + + QString supposedName = dependGrp.readEntry(name, QString()); + if (QFileInfo::exists(supposedName)) + return supposedName; + + if ((supposedName = QStandardPaths::findExecutable(name)).isEmpty()) + return QString(); + + // Because an executable file has been found, its path is remembered + // in order to avoid being searched next time + dependGrp.writeEntry(name, supposedName); + + return supposedName; +} + //! Checks if a returned status ("exit code") of an archiving-related process is OK /*! \param arcType A short QString which contains an identifier of the type of the archive. diff --git a/krusader/krdebuglogger.h b/krusader/krdebuglogger.h --- a/krusader/krdebuglogger.h +++ b/krusader/krdebuglogger.h @@ -24,6 +24,7 @@ // QtCore #include +#include #include #include