diff --git a/krArc/krarc.h b/krArc/krarc.h --- a/krArc/krarc.h +++ b/krArc/krarc.h @@ -79,7 +79,7 @@ private: void get(const QUrl &url, int tries); - /** checks if the exit code is OK. */ + /** checks if a returned status ("exit code") of an archiving-related process is OK. */ bool checkStatus(int exitCode); /** service function for parseLine. */ QString nextWord(QString &s, char d = ' '); diff --git a/krArc/krarc.cpp b/krArc/krarc.cpp --- a/krArc/krarc.cpp +++ b/krArc/krarc.cpp @@ -1637,16 +1637,7 @@ { KRFUNC; KRDEBUG(exitCode); - - // if this code is changed, the code of KRarcHandler::checkStatus() must be reviewed - if (arcType == "zip" || arcType == "rar" || arcType == "7z") - return exitCode == 0 || exitCode == 1; - else if (arcType == "ace" || arcType == "bzip2" || arcType == "lha" || arcType == "rpm" || arcType == "arj") - return exitCode == 0; - else if (arcType == "gzip" || arcType == "lzma" || arcType == "xz") - return exitCode == 0 || exitCode == 2; - else - return exitCode == 0; + return KrArcBaseManager::checkStatus(arcType, exitCode); } void kio_krarcProtocol::checkIf7zIsEncrypted(bool &encrypted, QString fileName) diff --git a/krArc/krarcbasemanager.h b/krArc/krarcbasemanager.h --- a/krArc/krarcbasemanager.h +++ b/krArc/krarcbasemanager.h @@ -41,6 +41,8 @@ //! The maximum length of a short QString that represents the type of a file static const int maxLenType; + static bool checkStatus(const QString &, int); + public: KrArcBaseManager() {} QString detectArchive(bool &, QString, bool = true, bool = false); diff --git a/krArc/krarcbasemanager.cpp b/krArc/krarcbasemanager.cpp --- a/krArc/krarcbasemanager.cpp +++ b/krArc/krarcbasemanager.cpp @@ -34,6 +34,26 @@ int KrArcBaseManager::autoDetectElems = sizeof(autoDetectParams) / sizeof(AutoDetectParams); const int KrArcBaseManager::maxLenType = 5; +//! 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. + \param exitCode The returned status ("exit code") of an archiving-related process. + \return If the exit code means that the archiving-related process ended without errors. +*/ +bool KrArcBaseManager::checkStatus(const QString &arcType, int exitCode) +{ + if (arcType == "zip" || arcType == "rar" || arcType == "7z") + return exitCode == 0 || exitCode == 1; + else if (arcType == "ace" || arcType == "bzip2" || arcType == "lha" || arcType == "rpm" || arcType == "cpio" || + arcType == "tar" || arcType == "tarz" || arcType == "tbz" || arcType == "tgz" || arcType == "arj" || + arcType == "deb" || arcType == "tlz" || arcType == "txz") + return exitCode == 0; + else if (arcType == "gzip" || arcType == "lzma" || arcType == "xz") + return exitCode == 0 || exitCode == 2; + else + return exitCode == 0; +} + QString KrArcBaseManager::detectArchive(bool &encrypted, QString fileName, bool checkEncrypted, bool fast) { encrypted = false; diff --git a/krusader/VFS/krarchandler.h b/krusader/VFS/krarchandler.h --- a/krusader/VFS/krarchandler.h +++ b/krusader/VFS/krarchandler.h @@ -85,7 +85,7 @@ // detects the archive type void checkIf7zIsEncrypted(bool &, QString); private: - // checks if the returned status is correct + //! checks if a returned status ("exit code") of an archiving-related process is OK static bool checkStatus(QString type, int exitCode); static bool openWallet(); diff --git a/krusader/VFS/krarchandler.cpp b/krusader/VFS/krarchandler.cpp --- a/krusader/VFS/krarchandler.cpp +++ b/krusader/VFS/krarchandler.cpp @@ -140,7 +140,7 @@ type = getShortTypeFromMime(type); } - if ((type == "zip" || type == "/zip") && lst.contains("unzip")) + if (type == "zip" && lst.contains("unzip")) return true; else if (type == "tar" && lst.contains("tar")) return true; @@ -686,17 +686,7 @@ bool KRarcHandler::checkStatus(QString type, int exitCode) { - // if this code is changed, the code of kio_krarcProtocol::checkStatus() must be reviewed - if (type == "zip" || type == "rar" || type == "7z") - return exitCode == 0 || exitCode == 1; - else if (type == "ace" || type == "bzip2" || type == "lha" || type == "rpm" || type == "cpio" || - type == "tar" || type == "tarz" || type == "tbz" || type == "tgz" || type == "arj" || - type == "deb" || type == "tlz" || type == "txz") - return exitCode == 0; - else if (type == "gzip" || type == "lzma" || type == "xz") - return exitCode == 0 || exitCode == 2; - else - return exitCode == 0; + return KrArcBaseManager::checkStatus(type, exitCode); } void KRarcHandler::checkIf7zIsEncrypted(bool &encrypted, QString fileName)