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 #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
00067 ulong uncompressedSize;
00068 quint32 crc;
00069 bool internal;
00070 int zipError;
00071
00072 QuaZipFile(const QuaZipFile& that);
00073 QuaZipFile& operator=(const QuaZipFile& that);
00074 void resetZipError()const {setZipError(UNZ_OK);}
00075
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