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 <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   private:
00119     QuaZipPrivate *p;
00120     // not (and will not be) implemented
00121     QuaZip(const QuaZip& that);
00122     // not (and will not be) implemented
00123     QuaZip& operator=(const QuaZip& that);
00124   public:
00126 
00127     QuaZip();
00129     QuaZip(const QString& zipName);
00131 
00132     QuaZip(QIODevice *ioDevice);
00134 
00135     ~QuaZip();
00137 
00173     bool open(Mode mode, zlib_filefunc_def *ioApi =NULL);
00175 
00178     void close();
00180 
00185     void setFileNameCodec(QTextCodec *fileNameCodec);
00187 
00190     void setFileNameCodec(const char *fileNameCodecName);
00192     QTextCodec* getFileNameCodec() const;
00194 
00196     void setCommentCodec(QTextCodec *commentCodec);
00198 
00201     void setCommentCodec(const char *commentCodecName);
00203     QTextCodec* getCommentCodec() const;
00205 
00210     QString getZipName() const;
00212 
00217     void setZipName(const QString& zipName);
00219 
00223     QIODevice *getIoDevice() const;
00225 
00230     void setIoDevice(QIODevice *ioDevice);
00232     Mode getMode() const;
00234     bool isOpen() const;
00236 
00244     int getZipError() const;
00246 
00249     int getEntriesCount() const;
00251     QString getComment() const;
00253 
00257     void setComment(const QString& comment);
00259 
00262     bool goToFirstFile();
00264 
00281     bool goToNextFile();
00283 
00307     bool setCurrentFile(const QString& fileName, CaseSensitivity cs =csDefault);
00309     bool hasCurrentFile() const;
00311 
00326     bool getCurrentFileInfo(QuaZipFileInfo* info)const;
00328 
00334     QString getCurrentFileName()const;
00336 
00351     unzFile getUnzFile();
00353 
00357     zipFile getZipFile();
00359 
00382     void setDataDescriptorWritingEnabled(bool enabled);
00384 
00387     bool isDataDescriptorWritingEnabled() const;
00389 
00395     QStringList getFileNameList() const;
00397 
00403     QList<QuaZipFileInfo> getFileInfoList() const;
00404 };
00405 
00406 #endif

Generated on 19 Dec 2011 for QuaZIP by  doxygen 1.6.1