QuaZIP  quazip-0-5
quazip.h
1 #ifndef QUA_ZIP_H
2 #define QUA_ZIP_H
3 
4 /*
5 Copyright (C) 2005-2011 Sergey A. Tachenov
6 
7 This program is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or (at
10 your option) any later version.
11 
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
15 General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 
21 See COPYING file for the full LGPL text.
22 
23 Original ZIP package is copyrighted by Gilles Vollant, see
24 quazip/(un)zip.h files for details, basically it's zlib license.
25  **/
26 
27 #include <QString>
28 #include <QStringList>
29 #include <QTextCodec>
30 
31 #include "zip.h"
32 #include "unzip.h"
33 
34 #include "quazip_global.h"
35 #include "quazipfileinfo.h"
36 
37 // just in case it will be defined in the later versions of the ZIP/UNZIP
38 #ifndef UNZ_OPENERROR
39 // define additional error code
40 #define UNZ_OPENERROR -1000
41 #endif
42 
43 class QuaZipPrivate;
44 
46 
83 class QUAZIP_EXPORT QuaZip {
84  friend class QuaZipPrivate;
85  public:
87  enum Constants {
88  MAX_FILE_NAME_LENGTH=256
91  };
93  enum Mode {
97  mdAppend,
105  mdAdd
106  };
108 
114  csDefault=0,
115  csSensitive=1,
116  csInsensitive=2
117  };
118  static Qt::CaseSensitivity convertCaseSensitivity(CaseSensitivity);
119  private:
120  QuaZipPrivate *p;
121  // not (and will not be) implemented
122  QuaZip(const QuaZip& that);
123  // not (and will not be) implemented
124  QuaZip& operator=(const QuaZip& that);
125  public:
127 
128  QuaZip();
130  QuaZip(const QString& zipName);
132 
133  QuaZip(QIODevice *ioDevice);
135 
136  ~QuaZip();
138 
174  bool open(Mode mode, zlib_filefunc_def *ioApi =NULL);
176 
179  void close();
181 
186  void setFileNameCodec(QTextCodec *fileNameCodec);
188 
191  void setFileNameCodec(const char *fileNameCodecName);
193  QTextCodec* getFileNameCodec() const;
195 
197  void setCommentCodec(QTextCodec *commentCodec);
199 
202  void setCommentCodec(const char *commentCodecName);
204  QTextCodec* getCommentCodec() const;
206 
211  QString getZipName() const;
213 
218  void setZipName(const QString& zipName);
220 
224  QIODevice *getIoDevice() const;
226 
231  void setIoDevice(QIODevice *ioDevice);
233  Mode getMode() const;
235  bool isOpen() const;
237 
245  int getZipError() const;
247 
250  int getEntriesCount() const;
252  QString getComment() const;
254 
262  void setComment(const QString& comment);
264 
267  bool goToFirstFile();
269 
286  bool goToNextFile();
288 
312  bool setCurrentFile(const QString& fileName, CaseSensitivity cs =csDefault);
314  bool hasCurrentFile() const;
316 
331  bool getCurrentFileInfo(QuaZipFileInfo* info)const;
333 
339  QString getCurrentFileName()const;
341 
356  unzFile getUnzFile();
358 
362  zipFile getZipFile();
364 
387  void setDataDescriptorWritingEnabled(bool enabled);
389 
392  bool isDataDescriptorWritingEnabled() const;
394 
400  QStringList getFileNameList() const;
402 
408  QList<QuaZipFileInfo> getFileInfoList() const;
409 };
410 
411 #endif