QuaZIP quazip-0-9
quazip.h
1#ifndef QUA_ZIP_H
2#define QUA_ZIP_H
3
4/*
5Copyright (C) 2005-2014 Sergey A. Tachenov
6
7This file is part of QuaZIP.
8
9QuaZIP is free software: you can redistribute it and/or modify
10it under the terms of the GNU Lesser General Public License as published by
11the Free Software Foundation, either version 2.1 of the License, or
12(at your option) any later version.
13
14QuaZIP is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License
20along with QuaZIP. If not, see <http://www.gnu.org/licenses/>.
21
22See COPYING file for the full LGPL text.
23
24Original ZIP package is copyrighted by Gilles Vollant, see
25quazip/(un)zip.h files for details, basically it's zlib license.
26 **/
27
28#include <QtCore/QString>
29#include <QtCore/QStringList>
30#include <QtCore/QTextCodec>
31
32#include "zip.h"
33#include "unzip.h"
34
35#include "quazip_global.h"
36#include "quazipfileinfo.h"
37
38// just in case it will be defined in the later versions of the ZIP/UNZIP
39#ifndef UNZ_OPENERROR
40// define additional error code
41#define UNZ_OPENERROR -1000
42#endif
43
44class QuaZipPrivate;
45
47
84class QUAZIP_EXPORT QuaZip {
85 friend class QuaZipPrivate;
86 public:
88 enum Constants {
89 MAX_FILE_NAME_LENGTH=256
92 };
94 enum Mode {
98 mdAppend,
106 mdAdd
107 };
109
115 csDefault=0,
116 csSensitive=1,
117 csInsensitive=2
118 };
120
126 static Qt::CaseSensitivity convertCaseSensitivity(
127 CaseSensitivity cs);
128 private:
129 QuaZipPrivate *p;
130 // not (and will not be) implemented
131 QuaZip(const QuaZip& that);
132 // not (and will not be) implemented
133 QuaZip& operator=(const QuaZip& that);
134 public:
136
137 QuaZip();
139 QuaZip(const QString& zipName);
141
142 QuaZip(QIODevice *ioDevice);
144
145 ~QuaZip();
147
193 bool open(Mode mode, zlib_filefunc_def *ioApi =NULL);
195
217 void close();
219
224 void setFileNameCodec(QTextCodec *fileNameCodec);
226
229 void setFileNameCodec(const char *fileNameCodecName);
231
235 void setOsCode(uint osCode);
237 uint getOsCode() const;
239 QTextCodec* getFileNameCodec() const;
241
243 void setCommentCodec(QTextCodec *commentCodec);
245
248 void setCommentCodec(const char *commentCodecName);
250 QTextCodec* getCommentCodec() const;
252
257 QString getZipName() const;
259
264 void setZipName(const QString& zipName);
266
270 QIODevice *getIoDevice() const;
272
277 void setIoDevice(QIODevice *ioDevice);
279 Mode getMode() const;
281 bool isOpen() const;
283
291 int getZipError() const;
293
296 int getEntriesCount() const;
298 QString getComment() const;
300
308 void setComment(const QString& comment);
310
313 bool goToFirstFile();
315
332 bool goToNextFile();
334
358 bool setCurrentFile(const QString& fileName, CaseSensitivity cs =csDefault);
360 bool hasCurrentFile() const;
362
383 bool getCurrentFileInfo(QuaZipFileInfo* info)const;
385
393 bool getCurrentFileInfo(QuaZipFileInfo64* info)const;
395
401 QString getCurrentFileName()const;
403
418 unzFile getUnzFile();
420
424 zipFile getZipFile();
426
453 void setDataDescriptorWritingEnabled(bool enabled);
455
458 bool isDataDescriptorWritingEnabled() const;
460
466 QStringList getFileNameList() const;
468
480 QList<QuaZipFileInfo> getFileInfoList() const;
482
490 QList<QuaZipFileInfo64> getFileInfoList64() const;
492
505 void setZip64Enabled(bool zip64);
507
512 bool isZip64Enabled() const;
514
527 void setUtf8Enabled(bool utf8);
529
534 bool isUtf8Enabled() const;
536
539 bool isAutoClose() const;
541
561 void setAutoClose(bool autoClose) const;
563
592 static void setDefaultFileNameCodec(QTextCodec *codec);
598 static void setDefaultFileNameCodec(const char *codecName);
600
603 static void setDefaultOsCode(uint osCode);
605
608 static uint getDefaultOsCode();
609};
610
611#endif
All the internal stuff for the QuaZip class.
Definition quazip.cpp:41
ZIP archive.
Definition quazip.h:84
Mode
Open mode of the ZIP file.
Definition quazip.h:94
@ mdCreate
ZIP file was created with open() call.
Definition quazip.h:97
@ mdUnzip
ZIP file is open for reading files inside it.
Definition quazip.h:96
@ mdNotOpen
ZIP file is not open. This is the initial mode.
Definition quazip.h:95
CaseSensitivity
Case sensitivity for the file names.
Definition quazip.h:114
Constants
Useful constants.
Definition quazip.h:88
Information about a file inside archive (with zip64 support).
Definition quazipfileinfo.h:85
Information about a file inside archive.
Definition quazipfileinfo.h:45