1/* This file is part of the KDE libraries
2 SPDX-FileCopyrightText: 2002 Holger Schroeder <holger-kde@holgis.net>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KZIPFILEENTRY_H
8#define KZIPFILEENTRY_H
9
10#include "karchive.h"
11
12class KZip;
13/*!
14 * \class KZipFileEntry
15 * \inmodule KArchive
16 *
17 * \brief Represents a file in a zip archive.
18 */
19class KARCHIVE_EXPORT KZipFileEntry : public KArchiveFile
20{
21public:
22 /*!
23 * Creates a new zip file entry. Do not call this, KZip takes care of it.
24 */
25 KZipFileEntry(KZip *zip,
26 const QString &name,
27 int access,
28 const QDateTime &date,
29 const QString &user,
30 const QString &group,
31 const QString &symlink,
32 const QString &path,
33 qint64 start,
34 qint64 uncompressedSize,
35 int encoding,
36 qint64 compressedSize);
37
38 ~KZipFileEntry() override;
39
40 /*!
41 *
42 */
43 int encoding() const;
44
45 /*!
46 * Only used when writing
47 */
48 qint64 compressedSize() const;
49
50 /*!
51 * Only used when writing
52 */
53 void setCompressedSize(qint64 compressedSize);
54
55 /*!
56 * Header start: only used when writing
57 */
58 void setHeaderStart(qint64 headerstart);
59 /*!
60 * Header start: only used when writing
61 */
62 qint64 headerStart() const;
63
64 /*!
65 * CRC: only used when writing
66 */
67 unsigned long crc32() const;
68
69 /*!
70 * CRC: only used when writing
71 */
72 void setCRC32(unsigned long crc32);
73
74 /*!
75 * Name with complete path - KArchiveFile::name() is the filename only (no path)
76 */
77 const QString &path() const;
78
79 /*!
80 * Returns the content of this file.
81 *
82 * \note The data returned by this call is not cached.
83 *
84 * \warning This method loads the entire file content into memory at once. For large files or untrusted archives, this could cause excessive memory
85 * allocation. Consider reading in chunks using createDevice() instead when dealing with archives from untrusted sources.
86 */
87 QByteArray data() const override;
88
89 /*!
90 * This method returns a QIODevice to read the file contents.
91 *
92 * This is obviously for reading only.
93 *
94 * Note that the ownership of the device is being transferred to the caller,
95 * who will have to delete it.
96 *
97 * The returned device auto-opens (in readonly mode), no need to open it.
98 *
99 * \note It can return nullptr
100 */
101 QIODevice *createDevice() const override;
102
103private:
104 class KZipFileEntryPrivate;
105 KZipFileEntryPrivate *const d;
106};
107
108#endif
109

source code of karchive/src/kzipfileentry.h