File indexing completed on 2024-04-21 03:49:47

0001 // SPDX-License-Identifier: LGPL-2.1-only WITH Qt-LGPL-exception-1.1 OR LGPL-3.0-only WITH Qt-LGPL-exception-1.1 OR GPL-3.0-only OR LicenseRef-Qt-Commercial
0002 //
0003 // SPDX-FileCopyrightText: 2015 The Qt Company Ltd. <https://www.qt.io/licensing/>
0004 // This file is based on qzipreader_p.h from Qt with the original license
0005 // below, taken from
0006 // https://code.qt.io/cgit/qt/qt.git/plain/src/gui/text/qzipreader_p.h
0007 
0008 #ifndef MARBLEZIPREADER_H
0009 #define MARBLEZIPREADER_H
0010 
0011 #ifndef QT_NO_TEXTODFWRITER
0012 
0013 //
0014 //  W A R N I N G
0015 //  -------------
0016 //
0017 // This file is not part of the Qt API.  It exists for the convenience
0018 // of the QZipReader class.  This header file may change from
0019 // version to version without notice, or even be removed.
0020 //
0021 // We mean it.
0022 //
0023 
0024 #include <QDateTime>
0025 #include <QFile>
0026 #include <QString>
0027 
0028 #include <marble_export.h>
0029 
0030 namespace Marble {
0031 
0032 class MarbleZipReaderPrivate;
0033 
0034 class MARBLE_EXPORT MarbleZipReader
0035 {
0036 public:
0037     MarbleZipReader(const QString &fileName, QIODevice::OpenMode mode = QIODevice::ReadOnly );
0038 
0039     explicit MarbleZipReader(QIODevice *device);
0040     ~MarbleZipReader();
0041 
0042     QIODevice* device() const;
0043 
0044     bool isReadable() const;
0045     bool exists() const;
0046 
0047     struct MARBLE_EXPORT FileInfo
0048     {
0049         FileInfo();
0050         FileInfo(const FileInfo &other);
0051         ~FileInfo();
0052         FileInfo &operator=(const FileInfo &other);
0053         bool isValid() const;
0054         QString filePath;
0055         uint isDir : 1;
0056         uint isFile : 1;
0057         uint isSymLink : 1;
0058         QFile::Permissions permissions;
0059         uint crc32;
0060         qint64 size;
0061         QDateTime lastModified;
0062         void *d;
0063     };
0064 
0065     QList<FileInfo> fileInfoList() const;
0066     int count() const;
0067 
0068     FileInfo entryInfoAt(int index) const;
0069     QByteArray fileData(const QString &fileName) const;
0070     bool extractAll(const QString &destinationDir) const;
0071 
0072     enum Status {
0073         NoError,
0074         FileReadError,
0075         FileOpenError,
0076         FilePermissionsError,
0077         FileError
0078     };
0079 
0080     Status status() const;
0081 
0082     void close();
0083 
0084 private:
0085     MarbleZipReaderPrivate *d;
0086     Q_DISABLE_COPY(MarbleZipReader)
0087 };
0088 
0089 }
0090 
0091 #endif // QT_NO_TEXTODFWRITER
0092 #endif // MARBLEZIPREADER_H