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