QuaZIP quazip-0-5
|
00001 #ifndef QUA_ZIP_H 00002 #define QUA_ZIP_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 <QString> 00028 #include <QStringList> 00029 #include <QTextCodec> 00030 00031 #include "zip.h" 00032 #include "unzip.h" 00033 00034 #include "quazip_global.h" 00035 #include "quazipfileinfo.h" 00036 00037 // just in case it will be defined in the later versions of the ZIP/UNZIP 00038 #ifndef UNZ_OPENERROR 00039 // define additional error code 00040 #define UNZ_OPENERROR -1000 00041 #endif 00042 00043 class QuaZipPrivate; 00044 00046 00083 class QUAZIP_EXPORT QuaZip { 00084 friend class QuaZipPrivate; 00085 public: 00087 enum Constants { 00088 MAX_FILE_NAME_LENGTH=256 00091 }; 00093 enum Mode { 00094 mdNotOpen, 00095 mdUnzip, 00096 mdCreate, 00097 mdAppend, 00105 mdAdd 00106 }; 00108 00113 enum CaseSensitivity { 00114 csDefault=0, 00115 csSensitive=1, 00116 csInsensitive=2 00117 }; 00118 static Qt::CaseSensitivity convertCaseSensitivity(CaseSensitivity); 00119 private: 00120 QuaZipPrivate *p; 00121 // not (and will not be) implemented 00122 QuaZip(const QuaZip& that); 00123 // not (and will not be) implemented 00124 QuaZip& operator=(const QuaZip& that); 00125 public: 00127 00128 QuaZip(); 00130 QuaZip(const QString& zipName); 00132 00133 QuaZip(QIODevice *ioDevice); 00135 00136 ~QuaZip(); 00138 00174 bool open(Mode mode, zlib_filefunc_def *ioApi =NULL); 00176 00179 void close(); 00181 00186 void setFileNameCodec(QTextCodec *fileNameCodec); 00188 00191 void setFileNameCodec(const char *fileNameCodecName); 00193 QTextCodec* getFileNameCodec() const; 00195 00197 void setCommentCodec(QTextCodec *commentCodec); 00199 00202 void setCommentCodec(const char *commentCodecName); 00204 QTextCodec* getCommentCodec() const; 00206 00211 QString getZipName() const; 00213 00218 void setZipName(const QString& zipName); 00220 00224 QIODevice *getIoDevice() const; 00226 00231 void setIoDevice(QIODevice *ioDevice); 00233 Mode getMode() const; 00235 bool isOpen() const; 00237 00245 int getZipError() const; 00247 00250 int getEntriesCount() const; 00252 QString getComment() const; 00254 00262 void setComment(const QString& comment); 00264 00267 bool goToFirstFile(); 00269 00286 bool goToNextFile(); 00288 00312 bool setCurrentFile(const QString& fileName, CaseSensitivity cs =csDefault); 00314 bool hasCurrentFile() const; 00316 00331 bool getCurrentFileInfo(QuaZipFileInfo* info)const; 00333 00339 QString getCurrentFileName()const; 00341 00356 unzFile getUnzFile(); 00358 00362 zipFile getZipFile(); 00364 00387 void setDataDescriptorWritingEnabled(bool enabled); 00389 00392 bool isDataDescriptorWritingEnabled() const; 00394 00400 QStringList getFileNameList() const; 00402 00408 QList<QuaZipFileInfo> getFileInfoList() const; 00409 }; 00410 00411 #endif