File indexing completed on 2025-01-26 04:14:57
0001 /* 0002 * Copyright (C) 2015 Dan Leinir Turthra Jensen <admin@leinir.dk> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Lesser General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2.1 of the License, or (at your option) version 3, or any 0008 * later version accepted by the membership of KDE e.V. (or its 0009 * successor approved by the membership of KDE e.V.), which shall 0010 * act as a proxy defined in Section 6 of version 3 of the license. 0011 * 0012 * This library is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 * Lesser General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU Lesser General Public 0018 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 0019 * 0020 */ 0021 0022 #ifndef KRAR_H 0023 #define KRAR_H 0024 0025 #include <karchive.h> 0026 0027 /** 0028 * KRar is a class for reading archives in the rar format. Writing 0029 * is not supported. 0030 * @short A class for reading rar archives. 0031 * @author Dan Leinir Turthra Jensen <admin@leinir.dk> 0032 */ 0033 class KRar : public KArchive 0034 { 0035 public: 0036 /** 0037 * Creates an instance that operates on the given filename. 0038 * using the compression filter associated to given mimetype. 0039 * 0040 * @param filename is a local path (e.g. "/home/leinir/boop.rar") 0041 */ 0042 KRar(const QString &filename); 0043 0044 /** 0045 * Creates an instance that operates on the given device. 0046 * The device can be compressed (KFilterDev) or not (QFile, etc.). 0047 * @warning Do not assume that giving a QFile here will decompress the file, 0048 * in case it's compressed! 0049 * @param dev the device to access 0050 */ 0051 KRar(QIODevice *dev); 0052 0053 /** 0054 * If the rar file is still opened, then it will be 0055 * closed automatically by the destructor. 0056 */ 0057 ~KRar() override; 0058 0059 protected: 0060 /* 0061 * Writing is not supported by this class, will always fail. 0062 * @return always false 0063 */ 0064 bool doPrepareWriting(const QString &name, const QString &user, const QString &group, qint64 size, 0065 mode_t perm, const QDateTime &atime, const QDateTime &mtime, const QDateTime &ctime) override; 0066 0067 /* 0068 * Writing is not supported by this class, will always fail. 0069 * @return always false 0070 */ 0071 bool doFinishWriting(qint64 size) override; 0072 0073 /* 0074 * Writing is not supported by this class, will always fail. 0075 * @return always false 0076 */ 0077 bool doWriteDir(const QString &name, const QString &user, const QString &group, 0078 mode_t perm, const QDateTime &atime, const QDateTime &mtime, const QDateTime &ctime) override; 0079 0080 bool doWriteSymLink(const QString &name, const QString &target, 0081 const QString &user, const QString &group, mode_t perm, 0082 const QDateTime &atime, const QDateTime &mtime, const QDateTime &ctime) override; 0083 0084 /** 0085 * Opens the archive for reading. 0086 * Parses the directory listing of the archive 0087 * and creates the KArchiveDirectory/KArchiveFile entries. 0088 * 0089 */ 0090 bool openArchive(QIODevice::OpenMode mode) override; 0091 bool closeArchive() override; 0092 0093 protected: 0094 void virtual_hook(int id, void *data) override; 0095 0096 private: 0097 class Private; 0098 Private* d; 0099 }; 0100 0101 #endif//KRAR_H