File indexing completed on 2024-05-05 17:57:40

0001 /*
0002     SPDX-FileCopyrightText: 2003 Rafi Yanai <krusader@users.sf.net>
0003     SPDX-FileCopyrightText: 2003 Shie Erlich <krusader@users.sf.net>
0004     SPDX-FileCopyrightText: 2004-2022 Krusader Krew <https://krusader.org>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef KRARCBASEMANAGER_H
0010 #define KRARCBASEMANAGER_H
0011 
0012 #include <KConfigCore/KConfig>
0013 #include <KConfigCore/KConfigGroup>
0014 
0015 // QtCore
0016 #include <QFile>
0017 
0018 /*!
0019  * \brief An abstract base class for managing archives.
0020  */
0021 class KrArcBaseManager
0022 {
0023 private:
0024     //! Information about a type of archive and the bytes that are used to detect it.
0025     struct AutoDetectParams {
0026         QString type;
0027         int location;
0028         QByteArray detectionString;
0029     };
0030 
0031     static AutoDetectParams autoDetectParams[]; //! Information used to detect if a file is an archive
0032     static int autoDetectElems; //!< The size of autoDetectParams[]
0033 
0034 protected:
0035     //! The maximum length of a short QString that represents the type of a file
0036     static const int maxLenType;
0037     //! The configuration file for Krusader
0038     KConfig krConf;
0039     //! The 'Dependencies' config group
0040     KConfigGroup dependGrp;
0041 
0042     //! Search for the full path to a program
0043     QString fullPathName(const QString &name);
0044     //! Find the path to a 7z (or 7za) executable
0045     QString find7zExecutable();
0046 
0047     static bool checkStatus(const QString &, int);
0048 
0049 public:
0050     KrArcBaseManager();
0051     QString detectArchive(bool &, const QString &, bool = true, bool = false);
0052     virtual void checkIf7zIsEncrypted(bool &, QString) = 0;
0053     static QString getShortTypeFromMime(const QString &);
0054     virtual ~KrArcBaseManager()
0055     {
0056     }
0057 };
0058 
0059 #endif // KRARCBASEMANAGER_H