FGx  1
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
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 <QTextCodec>
29 
30 #include "zip.h"
31 #include "unzip.h"
32 
33 #include "quazip_global.h"
34 #include "quazipfileinfo.h"
35 
36 // just in case it will be defined in the later versions of the ZIP/UNZIP
37 #ifndef UNZ_OPENERROR
38 // define additional error code
39 #define UNZ_OPENERROR -1000
40 #endif
41 
42 class QuaZipPrivate;
43 
45 
82 class QUAZIP_EXPORT QuaZip {
83  friend class QuaZipPrivate;
84  public:
86  enum Constants {
87  MAX_FILE_NAME_LENGTH=256
90  };
92  enum Mode {
96  mdAppend,
104  mdAdd
105  };
107 
113  csDefault=0,
114  csSensitive=1,
115  csInsensitive=2
116  };
117  private:
118  QuaZipPrivate *p;
119  // not (and will not be) implemented
120  QuaZip(const QuaZip& that);
121  // not (and will not be) implemented
122  QuaZip& operator=(const QuaZip& that);
123  public:
125 
126  QuaZip();
128  QuaZip(const QString& zipName);
130 
131  QuaZip(QIODevice *ioDevice);
133 
134  ~QuaZip();
136 
172  bool open(Mode mode, zlib_filefunc_def *ioApi =NULL);
174 
177  void close();
179 
184  void setFileNameCodec(QTextCodec *fileNameCodec);
186 
189  void setFileNameCodec(const char *fileNameCodecName);
191  QTextCodec* getFileNameCodec() const;
193 
195  void setCommentCodec(QTextCodec *commentCodec);
197 
200  void setCommentCodec(const char *commentCodecName);
202  QTextCodec* getCommentCodec() const;
204 
209  QString getZipName() const;
211 
216  void setZipName(const QString& zipName);
218 
222  QIODevice *getIoDevice() const;
224 
229  void setIoDevice(QIODevice *ioDevice);
231  Mode getMode() const;
233  bool isOpen() const;
235 
243  int getZipError() const;
245 
248  int getEntriesCount() const;
250  QString getComment() const;
252 
256  void setComment(const QString& comment);
258 
261  bool goToFirstFile();
263 
280  bool goToNextFile();
282 
306  bool setCurrentFile(const QString& fileName, CaseSensitivity cs =csDefault);
308  bool hasCurrentFile() const;
310 
325  bool getCurrentFileInfo(QuaZipFileInfo* info)const;
327 
333  QString getCurrentFileName()const;
335 
350  unzFile getUnzFile();
352 
356  zipFile getZipFile();
357 };
358 
359 #endif
Constants
Useful constants.
Definition: quazip.h:86
ZIP file is not open. This is the initial mode.
Definition: quazip.h:93
Definition: ioapi.h:48
ZIP file was created with open() call.
Definition: quazip.h:95
Information about a file inside archive.
Definition: quazipfileinfo.h:35
Mode
Open mode of the ZIP file.
Definition: quazip.h:92
ZIP file is open for reading files inside it.
Definition: quazip.h:94
ZIP archive.
Definition: quazip.h:82
CaseSensitivity
Case sensitivity for the file names.
Definition: quazip.h:112
Definition: quazip.cpp:28