| 1 | /* This file is part of the KDE libraries |
| 2 | SPDX-FileCopyrightText: 2002 Laurence Anderson <l.d.anderson@warwick.ac.uk> |
| 3 | |
| 4 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 5 | */ |
| 6 | #ifndef KAR_H |
| 7 | #define KAR_H |
| 8 | |
| 9 | #include <karchive.h> |
| 10 | |
| 11 | /*! |
| 12 | * \class KAr |
| 13 | * \module KArchive |
| 14 | * |
| 15 | * KAr is a class for reading archives in ar format. Writing |
| 16 | * is not supported. Reading archives that contain files bigger than |
| 17 | * INT_MAX - 32 bytes is not supported. |
| 18 | * |
| 19 | * \brief A class for reading ar archives. |
| 20 | */ |
| 21 | class KARCHIVE_EXPORT KAr : public KArchive |
| 22 | { |
| 23 | Q_DECLARE_TR_FUNCTIONS(KAr) |
| 24 | |
| 25 | public: |
| 26 | /*! |
| 27 | * Creates an instance that operates on the given filename. |
| 28 | * |
| 29 | * \a filename is a local path (e.g. "/home/holger/myfile.ar") |
| 30 | */ |
| 31 | explicit KAr(const QString &filename); |
| 32 | |
| 33 | /*! |
| 34 | * Creates an instance that operates on the given device. |
| 35 | * |
| 36 | * The device can be compressed (KCompressionDevice) or not (QFile, etc.). |
| 37 | * |
| 38 | * \a dev the device to read from |
| 39 | */ |
| 40 | explicit KAr(QIODevice *dev); |
| 41 | |
| 42 | /*! |
| 43 | * If the ar file is still opened, then it will be |
| 44 | * closed automatically by the destructor. |
| 45 | */ |
| 46 | ~KAr() override; |
| 47 | |
| 48 | protected: |
| 49 | /* |
| 50 | * Writing is not supported by this class, will always fail. |
| 51 | * Returns always false |
| 52 | */ |
| 53 | bool doPrepareWriting(const QString &name, |
| 54 | const QString &user, |
| 55 | const QString &group, |
| 56 | qint64 size, |
| 57 | mode_t perm, |
| 58 | const QDateTime &atime, |
| 59 | const QDateTime &mtime, |
| 60 | const QDateTime &ctime) override; |
| 61 | |
| 62 | /* |
| 63 | * Writing is not supported by this class, will always fail. |
| 64 | * Returns always false |
| 65 | */ |
| 66 | bool doFinishWriting(qint64 size) override; |
| 67 | |
| 68 | /* |
| 69 | * Writing is not supported by this class, will always fail. |
| 70 | * Returns always false |
| 71 | */ |
| 72 | bool doWriteDir(const QString &name, |
| 73 | const QString &user, |
| 74 | const QString &group, |
| 75 | mode_t perm, |
| 76 | const QDateTime &atime, |
| 77 | const QDateTime &mtime, |
| 78 | const QDateTime &ctime) override; |
| 79 | |
| 80 | bool doWriteSymLink(const QString &name, |
| 81 | const QString &target, |
| 82 | const QString &user, |
| 83 | const QString &group, |
| 84 | mode_t perm, |
| 85 | const QDateTime &atime, |
| 86 | const QDateTime &mtime, |
| 87 | const QDateTime &ctime) override; |
| 88 | |
| 89 | /* |
| 90 | * Opens the archive for reading. |
| 91 | * Parses the directory listing of the archive |
| 92 | * and creates the KArchiveDirectory/KArchiveFile entries. |
| 93 | * |
| 94 | */ |
| 95 | bool openArchive(QIODevice::OpenMode mode) override; |
| 96 | bool closeArchive() override; |
| 97 | |
| 98 | protected: |
| 99 | void virtual_hook(int id, void *data) override; |
| 100 | |
| 101 | private: |
| 102 | class KArPrivate; |
| 103 | KArPrivate *const d; |
| 104 | }; |
| 105 | |
| 106 | #endif |
| 107 | |