QuaZIP quazip-0-7
|
00001 #ifndef QUA_ZIP_H 00002 #define QUA_ZIP_H 00003 00004 /* 00005 Copyright (C) 2005-2014 Sergey A. Tachenov 00006 00007 This file is part of QuaZIP. 00008 00009 QuaZIP is free software: you can redistribute it and/or modify 00010 it under the terms of the GNU Lesser General Public License as published by 00011 the Free Software Foundation, either version 3 of the License, or 00012 (at your option) any later version. 00013 00014 QuaZIP is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License 00020 along with QuaZIP. If not, see <http://www.gnu.org/licenses/>. 00021 00022 See COPYING file for the full LGPL text. 00023 00024 Original ZIP package is copyrighted by Gilles Vollant, see 00025 quazip/(un)zip.h files for details, basically it's zlib license. 00026 **/ 00027 00028 #include <QString> 00029 #include <QStringList> 00030 #include <QTextCodec> 00031 00032 #include "zip.h" 00033 #include "unzip.h" 00034 00035 #include "quazip_global.h" 00036 #include "quazipfileinfo.h" 00037 00038 // just in case it will be defined in the later versions of the ZIP/UNZIP 00039 #ifndef UNZ_OPENERROR 00040 // define additional error code 00041 #define UNZ_OPENERROR -1000 00042 #endif 00043 00044 class QuaZipPrivate; 00045 00047 00084 class QUAZIP_EXPORT QuaZip { 00085 friend class QuaZipPrivate; 00086 public: 00088 enum Constants { 00089 MAX_FILE_NAME_LENGTH=256 00092 }; 00094 enum Mode { 00095 mdNotOpen, 00096 mdUnzip, 00097 mdCreate, 00098 mdAppend, 00106 mdAdd 00107 }; 00109 00114 enum CaseSensitivity { 00115 csDefault=0, 00116 csSensitive=1, 00117 csInsensitive=2 00118 }; 00120 00126 static Qt::CaseSensitivity convertCaseSensitivity( 00127 CaseSensitivity cs); 00128 private: 00129 QuaZipPrivate *p; 00130 // not (and will not be) implemented 00131 QuaZip(const QuaZip& that); 00132 // not (and will not be) implemented 00133 QuaZip& operator=(const QuaZip& that); 00134 public: 00136 00137 QuaZip(); 00139 QuaZip(const QString& zipName); 00141 00142 QuaZip(QIODevice *ioDevice); 00144 00145 ~QuaZip(); 00147 00193 bool open(Mode mode, zlib_filefunc_def *ioApi =NULL); 00195 00217 void close(); 00219 00224 void setFileNameCodec(QTextCodec *fileNameCodec); 00226 00229 void setFileNameCodec(const char *fileNameCodecName); 00231 QTextCodec* getFileNameCodec() const; 00233 00235 void setCommentCodec(QTextCodec *commentCodec); 00237 00240 void setCommentCodec(const char *commentCodecName); 00242 QTextCodec* getCommentCodec() const; 00244 00249 QString getZipName() const; 00251 00256 void setZipName(const QString& zipName); 00258 00262 QIODevice *getIoDevice() const; 00264 00269 void setIoDevice(QIODevice *ioDevice); 00271 Mode getMode() const; 00273 bool isOpen() const; 00275 00283 int getZipError() const; 00285 00288 int getEntriesCount() const; 00290 QString getComment() const; 00292 00300 void setComment(const QString& comment); 00302 00305 bool goToFirstFile(); 00307 00324 bool goToNextFile(); 00326 00350 bool setCurrentFile(const QString& fileName, CaseSensitivity cs =csDefault); 00352 bool hasCurrentFile() const; 00354 00375 bool getCurrentFileInfo(QuaZipFileInfo* info)const; 00377 00385 bool getCurrentFileInfo(QuaZipFileInfo64* info)const; 00387 00393 QString getCurrentFileName()const; 00395 00410 unzFile getUnzFile(); 00412 00416 zipFile getZipFile(); 00418 00445 void setDataDescriptorWritingEnabled(bool enabled); 00447 00450 bool isDataDescriptorWritingEnabled() const; 00452 00458 QStringList getFileNameList() const; 00460 00472 QList<QuaZipFileInfo> getFileInfoList() const; 00474 00482 QList<QuaZipFileInfo64> getFileInfoList64() const; 00484 00497 void setZip64Enabled(bool zip64); 00499 00504 bool isZip64Enabled() const; 00506 00509 bool isAutoClose() const; 00511 00531 void setAutoClose(bool autoClose) const; 00533 00562 static void setDefaultFileNameCodec(QTextCodec *codec); 00568 static void setDefaultFileNameCodec(const char *codecName); 00569 }; 00570 00571 #endif