QuaZIP  quazip-0-4-3
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  private:
119  QuaZipPrivate *p;
120  // not (and will not be) implemented
121  QuaZip(const QuaZip& that);
122  // not (and will not be) implemented
123  QuaZip& operator=(const QuaZip& that);
124  public:
126 
127  QuaZip();
129  QuaZip(const QString& zipName);
131 
132  QuaZip(QIODevice *ioDevice);
134 
135  ~QuaZip();
137 
173  bool open(Mode mode, zlib_filefunc_def *ioApi =NULL);
175 
178  void close();
180 
185  void setFileNameCodec(QTextCodec *fileNameCodec);
187 
190  void setFileNameCodec(const char *fileNameCodecName);
192  QTextCodec* getFileNameCodec() const;
194 
196  void setCommentCodec(QTextCodec *commentCodec);
198 
201  void setCommentCodec(const char *commentCodecName);
203  QTextCodec* getCommentCodec() const;
205 
210  QString getZipName() const;
212 
217  void setZipName(const QString& zipName);
219 
223  QIODevice *getIoDevice() const;
225 
230  void setIoDevice(QIODevice *ioDevice);
232  Mode getMode() const;
234  bool isOpen() const;
236 
244  int getZipError() const;
246 
249  int getEntriesCount() const;
251  QString getComment() const;
253 
257  void setComment(const QString& comment);
259 
262  bool goToFirstFile();
264 
281  bool goToNextFile();
283 
307  bool setCurrentFile(const QString& fileName, CaseSensitivity cs =csDefault);
309  bool hasCurrentFile() const;
311 
326  bool getCurrentFileInfo(QuaZipFileInfo* info)const;
328 
334  QString getCurrentFileName()const;
336 
351  unzFile getUnzFile();
353 
357  zipFile getZipFile();
359 
382  void setDataDescriptorWritingEnabled(bool enabled);
384 
387  bool isDataDescriptorWritingEnabled() const;
389 
395  QStringList getFileNameList() const;
397 
403  QList<QuaZipFileInfo> getFileInfoList() const;
404 };
405 
406 #endif