QuaZIP quazip-0-2-3
|
00001 #ifndef QUA_ZIPFILE_H 00002 #define QUA_ZIPFILE_H 00003 00004 /* 00005 -- A kind of "standard" GPL license statement -- 00006 QuaZIP - a Qt/C++ wrapper for the ZIP/UNZIP package 00007 Copyright (C) 2005-2008 Sergey A. Tachenov 00008 00009 This program is free software; you can redistribute it and/or modify it 00010 under the terms of the GNU General Public License as published by the 00011 Free Software Foundation; either version 2 of the License, or (at your 00012 option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, but 00015 WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 00017 Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License along 00020 with this program; if not, write to the Free Software Foundation, Inc., 00021 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 00023 -- A kind of "standard" GPL license statement ends here -- 00024 00025 See COPYING file for GPL. 00026 00027 You are also permitted to use QuaZIP under the terms of LGPL (see 00028 COPYING.LGPL). You are free to choose either license, but please note 00029 that QuaZIP makes use of Qt, which is not licensed under LGPL. So if 00030 you are using Open Source edition of Qt, you therefore MUST use GPL for 00031 your code based on QuaZIP, since it would be also based on Qt in this 00032 case. If you are Qt commercial license owner, then you are free to use 00033 QuaZIP as long as you respect either GPL or LGPL for QuaZIP code. 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 // these two are for writing raw files 00080 ulong uncompressedSize; 00081 quint32 crc; 00082 bool internal; 00083 int zipError; 00084 // these are not supported nor implemented 00085 QuaZipFile(const QuaZipFile& that); 00086 QuaZipFile& operator=(const QuaZipFile& that); 00087 void resetZipError()const {setZipError(UNZ_OK);} 00088 // const, but sets zipError! 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