QuaZIP  quazip-0-5-1
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  };
119 
125  static Qt::CaseSensitivity convertCaseSensitivity(
126  CaseSensitivity cs);
127  private:
128  QuaZipPrivate *p;
129  // not (and will not be) implemented
130  QuaZip(const QuaZip& that);
131  // not (and will not be) implemented
132  QuaZip& operator=(const QuaZip& that);
133  public:
135 
136  QuaZip();
138  QuaZip(const QString& zipName);
140 
141  QuaZip(QIODevice *ioDevice);
143 
144  ~QuaZip();
146 
182  bool open(Mode mode, zlib_filefunc_def *ioApi =NULL);
184 
187  void close();
189 
194  void setFileNameCodec(QTextCodec *fileNameCodec);
196 
199  void setFileNameCodec(const char *fileNameCodecName);
201  QTextCodec* getFileNameCodec() const;
203 
205  void setCommentCodec(QTextCodec *commentCodec);
207 
210  void setCommentCodec(const char *commentCodecName);
212  QTextCodec* getCommentCodec() const;
214 
219  QString getZipName() const;
221 
226  void setZipName(const QString& zipName);
228 
232  QIODevice *getIoDevice() const;
234 
239  void setIoDevice(QIODevice *ioDevice);
241  Mode getMode() const;
243  bool isOpen() const;
245 
253  int getZipError() const;
255 
258  int getEntriesCount() const;
260  QString getComment() const;
262 
270  void setComment(const QString& comment);
272 
275  bool goToFirstFile();
277 
294  bool goToNextFile();
296 
320  bool setCurrentFile(const QString& fileName, CaseSensitivity cs =csDefault);
322  bool hasCurrentFile() const;
324 
339  bool getCurrentFileInfo(QuaZipFileInfo* info)const;
341 
347  QString getCurrentFileName()const;
349 
364  unzFile getUnzFile();
366 
370  zipFile getZipFile();
372 
395  void setDataDescriptorWritingEnabled(bool enabled);
397 
400  bool isDataDescriptorWritingEnabled() const;
402 
408  QStringList getFileNameList() const;
410 
416  QList<QuaZipFileInfo> getFileInfoList() const;
417 };
418 
419 #endif
Constants
Useful constants.
Definition: quazip.h:87
ZIP file is not open. This is the initial mode.
Definition: quazip.h:94
ZIP file was created with open() call.
Definition: quazip.h:96
Information about a file inside archive.
Definition: quazipfileinfo.h:36
Mode
Open mode of the ZIP file.
Definition: quazip.h:93
ZIP file is open for reading files inside it.
Definition: quazip.h:95
ZIP archive.
Definition: quazip.h:83
CaseSensitivity
Case sensitivity for the file names.
Definition: quazip.h:113
All the internal stuff for the QuaZip class.
Definition: quazip.cpp:37