File indexing completed on 2024-06-02 05:47:03

0001 /****************************************************************************
0002 **
0003 ** Copyright (C) 2008-2008 Trolltech ASA. All rights reserved.
0004 **
0005 ** This file is part of the QtGui module of the Qt Toolkit.
0006 **
0007 ** This file may be used under the terms of the GNU General Public
0008 ** License versions 2.0 or 3.0 as published by the Free Software
0009 ** Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3
0010 ** included in the packaging of this file.  Alternatively you may (at
0011 ** your option) use any later version of the GNU General Public
0012 ** License if such license has been publicly approved by Trolltech ASA
0013 ** (or its successors, if any) and the KDE Free Qt Foundation. In
0014 ** addition, as a special exception, Trolltech gives you certain
0015 ** additional rights. These rights are described in the Trolltech GPL
0016 ** Exception version 1.2, which can be found at
0017 ** http://www.trolltech.com/products/qt/gplexception/ and in the file
0018 ** GPL_EXCEPTION.txt in this package.
0019 **
0020 ** Please review the following information to ensure GNU General
0021 ** Public Licensing requirements will be met:
0022 ** http://trolltech.com/products/qt/licenses/licensing/opensource/. If
0023 ** you are unsure which license is appropriate for your use, please
0024 ** review the following information:
0025 ** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
0026 ** or contact the sales department at sales@trolltech.com.
0027 **
0028 ** In addition, as a special exception, Trolltech, as the sole
0029 ** copyright holder for Qt Designer, grants users of the Qt/Eclipse
0030 ** Integration plug-in the right for the Qt/Eclipse Integration to
0031 ** link to functionality provided by Qt Designer and its related
0032 ** libraries.
0033 **
0034 ** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
0035 ** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
0036 ** A PARTICULAR PURPOSE. Trolltech reserves all rights not expressly
0037 ** granted herein.
0038 **
0039 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
0040 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
0041 **
0042 ****************************************************************************/
0043 
0044 #ifndef GZIPREADER_H
0045 #define GZIPREADER_H
0046 
0047 //
0048 //  W A R N I N G
0049 //  -------------
0050 //
0051 // This file is not part of the Qt API.  It exists for the convenience
0052 // of the QLibrary class.  This header file may change from
0053 // version to version without notice, or even be removed.
0054 //
0055 // We mean it.
0056 //
0057 
0058 #include "rwidgets_global.h"
0059 #include <QtCore/qfile.h>
0060 #include <QtCore/qstring.h>
0061 class GZipReaderPrivate;
0062 
0063 namespace CZIP
0064 {
0065 class RWIDGET_EXPORT QZipReader
0066 {
0067 public:
0068     QZipReader(const QString& fileName, QIODevice::OpenMode mode= QIODevice::ReadOnly);
0069 
0070     explicit QZipReader(QIODevice* device);
0071     ~QZipReader();
0072 
0073     bool isReadable() const;
0074     bool exists() const;
0075 
0076     struct Q_AUTOTEST_EXPORT FileInfo
0077     {
0078         FileInfo();
0079         FileInfo(const FileInfo& other);
0080         ~FileInfo();
0081         FileInfo& operator=(const FileInfo& other);
0082         QString filePath;
0083         uint isDir : 1;
0084         uint isFile : 1;
0085         uint isSymLink : 1;
0086         QFile::Permissions permissions;
0087         uint crc32;
0088         qint64 size;
0089         void* d;
0090     };
0091 
0092     QList<FileInfo> fileInfoList() const;
0093     int count() const;
0094 
0095     FileInfo entryInfoAt(int index) const;
0096     QByteArray fileData(const QString& fileName) const;
0097     bool extractAll(const QString& destinationDir) const;
0098 
0099     enum Status
0100     {
0101         NoError,
0102         FileReadError,
0103         FileOpenError,
0104         FilePermissionsError,
0105         FileError
0106     };
0107 
0108     Status status() const;
0109 
0110     void close();
0111 
0112 private:
0113     GZipReaderPrivate* d;
0114     Q_DISABLE_COPY(QZipReader)
0115 };
0116 
0117 } // namespace CZIP
0118 
0119 #endif // QZIPREADER_H