KArchive

kar.h
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 */
20class KARCHIVE_EXPORT KAr : public KArchive
21{
22 Q_DECLARE_TR_FUNCTIONS(KAr)
23
24public:
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
45protected:
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
95protected:
96 void virtual_hook(int id, void *data) override;
97
98private:
99 class KArPrivate;
100 KArPrivate *const d;
101};
102
103#endif
KAr is a class for reading archives in ar format.
Definition kar.h:21
KArchive is a base class for reading and writing archives.
Definition karchive.h:41
virtual bool doFinishWriting(qint64 size)=0
Called after writing the data.
virtual bool doWriteDir(const QString &name, const QString &user, const QString &group, mode_t perm, const QDateTime &atime, const QDateTime &mtime, const QDateTime &ctime)=0
Write a directory to the archive.
virtual bool doWriteSymLink(const QString &name, const QString &target, const QString &user, const QString &group, mode_t perm, const QDateTime &atime, const QDateTime &mtime, const QDateTime &ctime)=0
Writes a symbolic link to the archive.
virtual bool closeArchive()=0
Closes the archive.
virtual bool doPrepareWriting(const QString &name, const QString &user, const QString &group, qint64 size, mode_t perm, const QDateTime &atime, const QDateTime &mtime, const QDateTime &ctime)=0
This virtual method must be implemented by subclasses.
virtual bool openArchive(QIODevice::OpenMode mode)=0
Opens an archive for reading or writing.
typedef OpenMode
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:15:57 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.