QuaZIP quazip-0-6-2
quazip.h
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 
00187     bool open(Mode mode, zlib_filefunc_def *ioApi =NULL);
00189 
00211     void close();
00213 
00218     void setFileNameCodec(QTextCodec *fileNameCodec);
00220 
00223     void setFileNameCodec(const char *fileNameCodecName);
00225     QTextCodec* getFileNameCodec() const;
00227 
00229     void setCommentCodec(QTextCodec *commentCodec);
00231 
00234     void setCommentCodec(const char *commentCodecName);
00236     QTextCodec* getCommentCodec() const;
00238 
00243     QString getZipName() const;
00245 
00250     void setZipName(const QString& zipName);
00252 
00256     QIODevice *getIoDevice() const;
00258 
00263     void setIoDevice(QIODevice *ioDevice);
00265     Mode getMode() const;
00267     bool isOpen() const;
00269 
00277     int getZipError() const;
00279 
00282     int getEntriesCount() const;
00284     QString getComment() const;
00286 
00294     void setComment(const QString& comment);
00296 
00299     bool goToFirstFile();
00301 
00318     bool goToNextFile();
00320 
00344     bool setCurrentFile(const QString& fileName, CaseSensitivity cs =csDefault);
00346     bool hasCurrentFile() const;
00348 
00369     bool getCurrentFileInfo(QuaZipFileInfo* info)const;
00371 
00379     bool getCurrentFileInfo(QuaZipFileInfo64* info)const;
00381 
00387     QString getCurrentFileName()const;
00389 
00404     unzFile getUnzFile();
00406 
00410     zipFile getZipFile();
00412 
00435     void setDataDescriptorWritingEnabled(bool enabled);
00437 
00440     bool isDataDescriptorWritingEnabled() const;
00442 
00448     QStringList getFileNameList() const;
00450 
00462     QList<QuaZipFileInfo> getFileInfoList() const;
00464 
00472     QList<QuaZipFileInfo64> getFileInfoList64() const;
00474 
00487     void setZip64Enabled(bool zip64);
00489 
00494     bool isZip64Enabled() const;
00496 
00499     bool isAutoClose() const;
00501 
00521     void setAutoClose(bool autoClose) const;
00523 
00552     static void setDefaultFileNameCodec(QTextCodec *codec);
00558     static void setDefaultFileNameCodec(const char *codecName);
00559 };
00560 
00561 #endif