KArchive

k7zip.h
1/* This file is part of the KDE libraries
2 SPDX-FileCopyrightText: 2011 Mario Bensi <mbensi@ipsquad.net>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6#ifndef K7ZIP_H
7#define K7ZIP_H
8
9#include <karchive.h>
10
11/**
12 * @class K7Zip k7zip.h K7Zip
13 *
14 * A class for reading / writing p7zip archives.
15 *
16 * @author Mario Bensi
17 */
18class KARCHIVE_EXPORT K7Zip : public KArchive
19{
20 Q_DECLARE_TR_FUNCTIONS(K7Zip)
21
22public:
23 /**
24 * Creates an instance that operates on the given filename
25 * using the compression filter associated to given mimetype.
26 *
27 * @param filename is a local path (e.g. "/home/user/myfile.7z")
28 */
29 explicit K7Zip(const QString &filename);
30
31 /**
32 * Creates an instance that operates on the given device.
33 * The device can be compressed (KCompressionDevice) or not (QFile, etc.).
34 * @warning Do not assume that giving a QFile here will decompress the file,
35 * in case it's compressed!
36 * @param dev the device to read from. If the source is compressed, the
37 * QIODevice must take care of decompression
38 */
39 explicit K7Zip(QIODevice *dev);
40
41 /**
42 * If the archive is still opened, then it will be
43 * closed automatically by the destructor.
44 */
45 ~K7Zip() override;
46
47protected:
48 /// Reimplemented from KArchive
49 bool doWriteSymLink(const QString &name,
50 const QString &target,
51 const QString &user,
52 const QString &group,
53 mode_t perm,
54 const QDateTime &atime,
55 const QDateTime &mtime,
56 const QDateTime &ctime) override;
57 /// Reimplemented from KArchive
58 bool doWriteDir(const QString &name,
59 const QString &user,
60 const QString &group,
61 mode_t perm,
62 const QDateTime &atime,
63 const QDateTime &mtime,
64 const QDateTime &ctime) override;
65 /// Reimplemented from KArchive
66 bool doPrepareWriting(const QString &name,
67 const QString &user,
68 const QString &group,
69 qint64 size,
70 mode_t perm,
71 const QDateTime &atime,
72 const QDateTime &mtime,
73 const QDateTime &ctime) override;
74 /// Reimplemented from KArchive
75 bool doFinishWriting(qint64 size) override;
76
77 /// Reimplemented from KArchive
78 bool doWriteData(const char *data, qint64 size) override;
79
80 /**
81 * Opens the archive for reading.
82 * Parses the directory listing of the archive
83 * and creates the KArchiveDirectory/KArchiveFile entries.
84 * @param mode the mode of the file
85 */
86 bool openArchive(QIODevice::OpenMode mode) override;
87 bool closeArchive() override;
88
89protected:
90 void virtual_hook(int id, void *data) override;
91
92private:
93 class K7ZipPrivate;
94 K7ZipPrivate *const d;
95};
96
97#endif
A class for reading / writing p7zip archives.
Definition k7zip.h:19
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.
virtual bool doWriteData(const char *data, qint64 size)
Write data into the current file.
Definition karchive.cpp:424
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:11:56 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.