quazipfile.h

00001 #ifndef QUA_ZIPFILE_H
00002 #define QUA_ZIPFILE_H
00003 
00004 /*
00005  * QuaZIP - a Qt/C++ wrapper for the ZIP/UNZIP package
00006  * Copyright (C) 2005 Sergey A. Tachenov
00007  * 
00008  * This program is free software; you can redistribute it and/or modify it
00009  * under the terms of the GNU General Public License as published by the
00010  * Free Software Foundation; either version 2 of the License, or (at your
00011  * option) any later version.
00012  * 
00013  * This program is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
00016  * Public License for more details.
00017  * 
00018  * You should have received a copy of the GNU General Public License along
00019  * with this program; if not, write to the Free Software Foundation, Inc.,
00020  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00021  **/
00022 
00023 #include <QIODevice>
00024 
00025 #include "quazip.h"
00026 #include "quazipnewinfo.h"
00027 
00029 
00058 class QuaZipFile: public QIODevice {
00059   Q_OBJECT
00060   private:
00061     QuaZip *zip;
00062     QString fileName;
00063     QuaZip::CaseSensitivity caseSensitivity;
00064     bool raw;
00065     qint64 writePos;
00066     // these two are for writing raw files
00067     ulong uncompressedSize;
00068     quint32 crc;
00069     bool internal;
00070     int zipError;
00071     // these are not supported nor implemented
00072     QuaZipFile(const QuaZipFile& that);
00073     QuaZipFile& operator=(const QuaZipFile& that);
00074     void resetZipError()const {setZipError(UNZ_OK);}
00075     // const, but sets zipError!
00076     void setZipError(int zipError)const;
00077   protected:
00079     qint64 readData(char *data, qint64 maxSize);
00081     qint64 writeData(const char *data, qint64 maxSize);
00082   public:
00084 
00087     QuaZipFile();
00089 
00094     QuaZipFile(QObject *parent);
00096 
00105     QuaZipFile(const QString& zipName, QObject *parent =NULL);
00107 
00116     QuaZipFile(const QString& zipName, const QString& fileName,
00117         QuaZip::CaseSensitivity cs =QuaZip::csDefault, QObject *parent =NULL);
00119 
00167     QuaZipFile(QuaZip *zip, QObject *parent =NULL);
00169 
00172     virtual ~QuaZipFile();
00174 
00183     QString getZipName()const;
00185 
00188     QuaZip* getZip()const;
00190 
00202     QString getFileName()const {return fileName;}
00204 
00215     QuaZip::CaseSensitivity getCaseSensitivity()const {return caseSensitivity;}
00217 
00241     QString getActualFileName()const;
00243 
00249     void setZipName(const QString& zipName);
00251 
00255     bool isRaw()const {return raw;}
00257 
00265     void setZip(QuaZip *zip);
00267 
00278     void setFileName(const QString& fileName, QuaZip::CaseSensitivity cs =QuaZip::csDefault);
00280 
00287     virtual bool open(OpenMode mode);
00289 
00293     bool open(OpenMode mode, const char *password)
00294     {return open(mode, NULL, NULL, false, password);}
00296 
00307     bool open(OpenMode mode, int *method, int *level, bool raw, const char *password =NULL);
00309 
00329     bool open(OpenMode mode, const QuaZipNewInfo& info,
00330         const char *password =NULL, quint32 crc =0,
00331         int method =Z_DEFLATED, int level =Z_DEFAULT_COMPRESSION, bool raw =false,
00332         int windowBits =-MAX_WBITS, int memLevel =DEF_MEM_LEVEL, int strategy =Z_DEFAULT_STRATEGY);
00334     virtual bool isSequential()const;
00336 
00357     virtual qint64 pos()const;
00359 
00375     virtual bool atEnd()const;
00377 
00389     virtual qint64 size()const;
00391 
00398     qint64 csize()const;
00400 
00408     qint64 usize()const;
00410 
00420     bool getFileInfo(QuaZipFileInfo *info);
00422 
00424     virtual void close();
00426     int getZipError()const {return zipError;}
00427 };
00428 
00429 #endif

Generated on Tue Mar 21 19:38:45 2006 for QuaZIP by  doxygen 1.4.6