1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QZIPREADER_H
5#define QZIPREADER_H
6
7#include <QtCore/private/qglobal_p.h>
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists for the convenience
14// of the QZipReader class. This header file may change from
15// version to version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <QtCore/qdatetime.h>
21#include <QtCore/qfile.h>
22#include <QtCore/qstring.h>
23
24QT_BEGIN_NAMESPACE
25
26class QZipReaderPrivate;
27
28class Q_CORE_EXPORT QZipReader
29{
30public:
31 explicit QZipReader(const QString &fileName, QIODevice::OpenMode mode = QIODevice::ReadOnly );
32
33 explicit QZipReader(QIODevice *device);
34 ~QZipReader();
35
36 QIODevice* device() const;
37
38 bool isReadable() const;
39 bool exists() const;
40
41 struct FileInfo
42 {
43 FileInfo() noexcept
44 : isDir(false), isFile(false), isSymLink(false), crc(0), size(0)
45 {}
46
47 bool isValid() const noexcept { return isDir || isFile || isSymLink; }
48
49 QString filePath;
50 uint isDir : 1;
51 uint isFile : 1;
52 uint isSymLink : 1;
53 QFile::Permissions permissions;
54 uint crc;
55 qint64 size;
56 QDateTime lastModified;
57 };
58
59 QList<FileInfo> fileInfoList() const;
60 int count() const;
61
62 FileInfo entryInfoAt(int index) const;
63 QByteArray fileData(const QString &fileName) const;
64 bool extractAll(const QString &destinationDir) const;
65
66 enum Status {
67 NoError,
68 FileReadError,
69 FileOpenError,
70 FilePermissionsError,
71 FileError
72 };
73
74 Status status() const;
75
76 void close();
77
78private:
79 QZipReaderPrivate *d;
80 Q_DISABLE_COPY_MOVE(QZipReader)
81};
82Q_DECLARE_TYPEINFO(QZipReader::FileInfo, Q_RELOCATABLE_TYPE);
83Q_DECLARE_TYPEINFO(QZipReader::Status, Q_PRIMITIVE_TYPE);
84
85QT_END_NAMESPACE
86
87#endif // QZIPREADER_H
88

source code of qtbase/src/corelib/io/qzipreader_p.h