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