quazipfile.h

    00001 #ifndef QUA_ZIPFILE_H
    00002 #define QUA_ZIPFILE_H
    00003
    00004 /*
    00005 Copyright (C) 2005-2011 Sergey A. Tachenov
    00006
    00007 This program is free software; you can redistribute it and/or modify it
    00008 under the terms of the GNU Lesser General Public License as published by
    00009 the Free Software Foundation; either version 2 of the License, or (at
    00010 your option) any later version.
    00011
    00012 This program is distributed in the hope that it will be useful, but
    00013 WITHOUT ANY WARRANTY; without even the implied warranty of
    00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
    00015 General Public License for more details.
    00016
    00017 You should have received a copy of the GNU Lesser General Public License
    00018 along with this program; if not, write to the Free Software Foundation,
    00019 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    00020
    00021 See COPYING file for the full LGPL text.
    00022
    00023 Original ZIP package is copyrighted by Gilles Vollant, see
    00024 quazip/(un)zip.h files for details, basically it's zlib license.
    00025  **/
    00026
    00027 #include <QIODevice>
    00028
    00029 #include "quazip_global.h"
    00030 #include "quazip.h"
    00031 #include "quazipnewinfo.h"
    00032
    00033 class QuaZipFilePrivate;
    00034
    00036
    00073 class QUAZIP_EXPORT QuaZipFile: public QIODevice {
    00074   friend class QuaZipFilePrivate;
    00075   Q_OBJECT
    00076   private:
    00077     QuaZipFilePrivate *p;
    00078     // these are not supported nor implemented
    00079     QuaZipFile(const QuaZipFile& that);
    00080     QuaZipFile& operator=(const QuaZipFile& that);
    00081   protected:
    00083     qint64 readData(char *data, qint64 maxSize);
    00085     qint64 writeData(const char *data, qint64 maxSize);
    00086   public:
    00088
    00091     QuaZipFile();
    00093
    00098     QuaZipFile(QObject *parent);
    00100
    00109     QuaZipFile(const QString& zipName, QObject *parent =NULL);
    00111
    00120     QuaZipFile(const QString& zipName, const QString& fileName,
    00121         QuaZip::CaseSensitivity cs =QuaZip::csDefault, QObject *parent =NULL);
    00123
    00171     QuaZipFile(QuaZip *zip, QObject *parent =NULL);
    00173
    00176     virtual ~QuaZipFile();
    00178
    00187     QString getZipName()const;
    00189
    00192     QuaZip* getZip()const;
    00194
    00206     QString getFileName() const;
    00208
    00219     QuaZip::CaseSensitivity getCaseSensitivity() const;
    00221
    00245     QString getActualFileName()const;
    00247
    00253     void setZipName(const QString& zipName);
    00255
    00259     bool isRaw() const;
    00261
    00269     void setZip(QuaZip *zip);
    00271
    00282     void setFileName(const QString& fileName, QuaZip::CaseSensitivity cs =QuaZip::csDefault);
    00284
    00291     virtual bool open(OpenMode mode);
    00293
    00297     inline bool open(OpenMode mode, const char *password)
    00298     {return open(mode, NULL, NULL, false, password);}
    00300
    00311     bool open(OpenMode mode, int *method, int *level, bool raw, const char *password =NULL);
    00313
    00340     bool open(OpenMode mode, const QuaZipNewInfo& info,
    00341         const char *password =NULL, quint32 crc =0,
    00342         int method =Z_DEFLATED, int level =Z_DEFAULT_COMPRESSION, bool raw =false,
    00343         int windowBits =-MAX_WBITS, int memLevel =DEF_MEM_LEVEL, int strategy =Z_DEFAULT_STRATEGY);
    00345     virtual bool isSequential()const;
    00347
    00368     virtual qint64 pos()const;
    00370
    00386     virtual bool atEnd()const;
    00388
    00400     virtual qint64 size()const;
    00402
    00409     qint64 csize()const;
    00411
    00419     qint64 usize()const;
    00421
    00431     bool getFileInfo(QuaZipFileInfo *info);
    00433
    00435     virtual void close();
    00437     int getZipError() const;
    00439     virtual qint64 bytesAvailable() const;
    00440 };
    00441
    00442 #endif