quazipfile.h
00001 #ifndef QUA_ZIPFILE_H
00002 #define QUA_ZIPFILE_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <QIODevice>
00037
00038 #include "quazip.h"
00039 #include "quazipnewinfo.h"
00040
00042
00071 class QuaZipFile: public QIODevice {
00072 Q_OBJECT
00073 private:
00074 QuaZip *zip;
00075 QString fileName;
00076 QuaZip::CaseSensitivity caseSensitivity;
00077 bool raw;
00078 qint64 writePos;
00079
00080 ulong uncompressedSize;
00081 quint32 crc;
00082 bool internal;
00083 int zipError;
00084
00085 QuaZipFile(const QuaZipFile& that);
00086 QuaZipFile& operator=(const QuaZipFile& that);
00087 void resetZipError()const {setZipError(UNZ_OK);}
00088
00089 void setZipError(int zipError)const;
00090 protected:
00092 qint64 readData(char *data, qint64 maxSize);
00094 qint64 writeData(const char *data, qint64 maxSize);
00095 public:
00097
00100 QuaZipFile();
00102
00107 QuaZipFile(QObject *parent);
00109
00118 QuaZipFile(const QString& zipName, QObject *parent =NULL);
00120
00129 QuaZipFile(const QString& zipName, const QString& fileName,
00130 QuaZip::CaseSensitivity cs =QuaZip::csDefault, QObject *parent =NULL);
00132
00180 QuaZipFile(QuaZip *zip, QObject *parent =NULL);
00182
00185 virtual ~QuaZipFile();
00187
00196 QString getZipName()const;
00198
00201 QuaZip* getZip()const;
00203
00215 QString getFileName()const {return fileName;}
00217
00228 QuaZip::CaseSensitivity getCaseSensitivity()const {return caseSensitivity;}
00230
00254 QString getActualFileName()const;
00256
00262 void setZipName(const QString& zipName);
00264
00268 bool isRaw()const {return raw;}
00270
00278 void setZip(QuaZip *zip);
00280
00291 void setFileName(const QString& fileName, QuaZip::CaseSensitivity cs =QuaZip::csDefault);
00293
00300 virtual bool open(OpenMode mode);
00302
00306 bool open(OpenMode mode, const char *password)
00307 {return open(mode, NULL, NULL, false, password);}
00309
00320 bool open(OpenMode mode, int *method, int *level, bool raw, const char *password =NULL);
00322
00342 bool open(OpenMode mode, const QuaZipNewInfo& info,
00343 const char *password =NULL, quint32 crc =0,
00344 int method =Z_DEFLATED, int level =Z_DEFAULT_COMPRESSION, bool raw =false,
00345 int windowBits =-MAX_WBITS, int memLevel =DEF_MEM_LEVEL, int strategy =Z_DEFAULT_STRATEGY);
00347 virtual bool isSequential()const;
00349
00370 virtual qint64 pos()const;
00372
00388 virtual bool atEnd()const;
00390
00402 virtual qint64 size()const;
00404
00411 qint64 csize()const;
00413
00421 qint64 usize()const;
00423
00433 bool getFileInfo(QuaZipFileInfo *info);
00435
00437 virtual void close();
00439 int getZipError()const {return zipError;}
00440 };
00441
00442 #endif