QuaZIP quazip-0-4-2
quazip.h
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 <QTextCodec>
00029 
00030 #include "zip.h"
00031 #include "unzip.h"
00032 
00033 #include "quazip_global.h"
00034 #include "quazipfileinfo.h"
00035 
00036 // just in case it will be defined in the later versions of the ZIP/UNZIP
00037 #ifndef UNZ_OPENERROR
00038 // define additional error code
00039 #define UNZ_OPENERROR -1000
00040 #endif
00041 
00042 class QuaZipPrivate;
00043 
00045 
00082 class QUAZIP_EXPORT QuaZip {
00083   friend class QuaZipPrivate;
00084   public:
00086     enum Constants {
00087       MAX_FILE_NAME_LENGTH=256 
00090     };
00092     enum Mode {
00093       mdNotOpen, 
00094       mdUnzip, 
00095       mdCreate, 
00096       mdAppend, 
00104       mdAdd 
00105     };
00107 
00112     enum CaseSensitivity {
00113       csDefault=0, 
00114       csSensitive=1, 
00115       csInsensitive=2 
00116     };
00117   private:
00118     QuaZipPrivate *p;
00119     // not (and will not be) implemented
00120     QuaZip(const QuaZip& that);
00121     // not (and will not be) implemented
00122     QuaZip& operator=(const QuaZip& that);
00123   public:
00125 
00126     QuaZip();
00128     QuaZip(const QString& zipName);
00130 
00131     QuaZip(QIODevice *ioDevice);
00133 
00134     ~QuaZip();
00136 
00172     bool open(Mode mode, zlib_filefunc_def *ioApi =NULL);
00174 
00177     void close();
00179 
00184     void setFileNameCodec(QTextCodec *fileNameCodec);
00186 
00189     void setFileNameCodec(const char *fileNameCodecName);
00191     QTextCodec* getFileNameCodec() const;
00193 
00195     void setCommentCodec(QTextCodec *commentCodec);
00197 
00200     void setCommentCodec(const char *commentCodecName);
00202     QTextCodec* getCommentCodec() const;
00204 
00209     QString getZipName() const;
00211 
00216     void setZipName(const QString& zipName);
00218 
00222     QIODevice *getIoDevice() const;
00224 
00229     void setIoDevice(QIODevice *ioDevice);
00231     Mode getMode() const;
00233     bool isOpen() const;
00235 
00243     int getZipError() const;
00245 
00248     int getEntriesCount() const;
00250     QString getComment() const;
00252 
00256     void setComment(const QString& comment);
00258 
00261     bool goToFirstFile();
00263 
00280     bool goToNextFile();
00282 
00306     bool setCurrentFile(const QString& fileName, CaseSensitivity cs =csDefault);
00308     bool hasCurrentFile() const;
00310 
00325     bool getCurrentFileInfo(QuaZipFileInfo* info)const;
00327 
00333     QString getCurrentFileName()const;
00335 
00350     unzFile getUnzFile();
00352 
00356     zipFile getZipFile();
00357 };
00358 
00359 #endif