diff options
Diffstat (limited to 'rbutil/rbutilqt/quazip/quazip.h')
-rw-r--r-- | rbutil/rbutilqt/quazip/quazip.h | 377 |
1 files changed, 301 insertions, 76 deletions
diff --git a/rbutil/rbutilqt/quazip/quazip.h b/rbutil/rbutilqt/quazip/quazip.h index ced1ea0f1a..ae2c8f494f 100644 --- a/rbutil/rbutilqt/quazip/quazip.h +++ b/rbutil/rbutilqt/quazip/quazip.h | |||
@@ -2,43 +2,37 @@ | |||
2 | #define QUA_ZIP_H | 2 | #define QUA_ZIP_H |
3 | 3 | ||
4 | /* | 4 | /* |
5 | -- A kind of "standard" GPL license statement -- | 5 | Copyright (C) 2005-2014 Sergey A. Tachenov |
6 | QuaZIP - a Qt/C++ wrapper for the ZIP/UNZIP package | ||
7 | Copyright (C) 2005-2007 Sergey A. Tachenov | ||
8 | 6 | ||
9 | This program is free software; you can redistribute it and/or modify it | 7 | This file is part of QuaZIP. |
10 | under the terms of the GNU General Public License as published by the | ||
11 | Free Software Foundation; either version 2 of the License, or (at your | ||
12 | option) any later version. | ||
13 | 8 | ||
14 | This program is distributed in the hope that it will be useful, but | 9 | QuaZIP is free software: you can redistribute it and/or modify |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | it under the terms of the GNU Lesser General Public License as published by |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | 11 | the Free Software Foundation, either version 2.1 of the License, or |
17 | Public License for more details. | 12 | (at your option) any later version. |
18 | 13 | ||
19 | You should have received a copy of the GNU General Public License along | 14 | QuaZIP is distributed in the hope that it will be useful, |
20 | with this program; if not, write to the Free Software Foundation, Inc., | 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | GNU Lesser General Public License for more details. | ||
22 | 18 | ||
23 | -- A kind of "standard" GPL license statement ends here -- | 19 | You should have received a copy of the GNU Lesser General Public License |
20 | along with QuaZIP. If not, see <http://www.gnu.org/licenses/>. | ||
24 | 21 | ||
25 | See COPYING file for GPL. | 22 | See COPYING file for the full LGPL text. |
26 | 23 | ||
27 | You are also permitted to use QuaZIP under the terms of LGPL (see | 24 | Original ZIP package is copyrighted by Gilles Vollant, see |
28 | COPYING.LGPL). You are free to choose either license, but please note | 25 | quazip/(un)zip.h files for details, basically it's zlib license. |
29 | that QuaZIP makes use of Qt, which is not licensed under LGPL. So if | ||
30 | you are using Open Source edition of Qt, you therefore MUST use GPL for | ||
31 | your code based on QuaZIP, since it would be also based on Qt in this | ||
32 | case. If you are Qt commercial license owner, then you are free to use | ||
33 | QuaZIP as long as you respect either GPL or LGPL for QuaZIP code. | ||
34 | **/ | 26 | **/ |
35 | 27 | ||
36 | #include <QString> | 28 | #include <QString> |
29 | #include <QStringList> | ||
37 | #include <QTextCodec> | 30 | #include <QTextCodec> |
38 | 31 | ||
39 | #include "zip.h" | 32 | #include "zip.h" |
40 | #include "unzip.h" | 33 | #include "unzip.h" |
41 | 34 | ||
35 | #include "quazip_global.h" | ||
42 | #include "quazipfileinfo.h" | 36 | #include "quazipfileinfo.h" |
43 | 37 | ||
44 | // just in case it will be defined in the later versions of the ZIP/UNZIP | 38 | // just in case it will be defined in the later versions of the ZIP/UNZIP |
@@ -47,6 +41,8 @@ QuaZIP as long as you respect either GPL or LGPL for QuaZIP code. | |||
47 | #define UNZ_OPENERROR -1000 | 41 | #define UNZ_OPENERROR -1000 |
48 | #endif | 42 | #endif |
49 | 43 | ||
44 | class QuaZipPrivate; | ||
45 | |||
50 | /// ZIP archive. | 46 | /// ZIP archive. |
51 | /** \class QuaZip quazip.h <quazip/quazip.h> | 47 | /** \class QuaZip quazip.h <quazip/quazip.h> |
52 | * This class implements basic interface to the ZIP archive. It can be | 48 | * This class implements basic interface to the ZIP archive. It can be |
@@ -85,7 +81,8 @@ QuaZIP as long as you respect either GPL or LGPL for QuaZIP code. | |||
85 | * detection using locale information. Does anyone know a good way to do | 81 | * detection using locale information. Does anyone know a good way to do |
86 | * it? | 82 | * it? |
87 | **/ | 83 | **/ |
88 | class QuaZip { | 84 | class QUAZIP_EXPORT QuaZip { |
85 | friend class QuaZipPrivate; | ||
89 | public: | 86 | public: |
90 | /// Useful constants. | 87 | /// Useful constants. |
91 | enum Constants { | 88 | enum Constants { |
@@ -119,17 +116,17 @@ class QuaZip { | |||
119 | csSensitive=1, ///< Case sensitive. | 116 | csSensitive=1, ///< Case sensitive. |
120 | csInsensitive=2 ///< Case insensitive. | 117 | csInsensitive=2 ///< Case insensitive. |
121 | }; | 118 | }; |
119 | /// Returns the actual case sensitivity for the specified QuaZIP one. | ||
120 | /** | ||
121 | \param cs The value to convert. | ||
122 | \returns If CaseSensitivity::csDefault, then returns the default | ||
123 | file name case sensitivity for the platform. Otherwise, just | ||
124 | returns the appropriate value from the Qt::CaseSensitivity enum. | ||
125 | */ | ||
126 | static Qt::CaseSensitivity convertCaseSensitivity( | ||
127 | CaseSensitivity cs); | ||
122 | private: | 128 | private: |
123 | QTextCodec *fileNameCodec, *commentCodec; | 129 | QuaZipPrivate *p; |
124 | QString zipName; | ||
125 | QString comment; | ||
126 | Mode mode; | ||
127 | union { | ||
128 | unzFile unzFile_f; | ||
129 | zipFile zipFile_f; | ||
130 | }; | ||
131 | bool hasCurrentFile_f; | ||
132 | int zipError; | ||
133 | // not (and will not be) implemented | 130 | // not (and will not be) implemented |
134 | QuaZip(const QuaZip& that); | 131 | QuaZip(const QuaZip& that); |
135 | // not (and will not be) implemented | 132 | // not (and will not be) implemented |
@@ -140,39 +137,83 @@ class QuaZip { | |||
140 | QuaZip(); | 137 | QuaZip(); |
141 | /// Constructs QuaZip object associated with ZIP file \a zipName. | 138 | /// Constructs QuaZip object associated with ZIP file \a zipName. |
142 | QuaZip(const QString& zipName); | 139 | QuaZip(const QString& zipName); |
140 | /// Constructs QuaZip object associated with ZIP file represented by \a ioDevice. | ||
141 | /** The IO device must be seekable, otherwise an error will occur when opening. */ | ||
142 | QuaZip(QIODevice *ioDevice); | ||
143 | /// Destroys QuaZip object. | 143 | /// Destroys QuaZip object. |
144 | /** Calls close() if necessary. */ | 144 | /** Calls close() if necessary. */ |
145 | ~QuaZip(); | 145 | ~QuaZip(); |
146 | /// Opens ZIP file. | 146 | /// Opens ZIP file. |
147 | /** Argument \a ioApi specifies IO function set for ZIP/UNZIP | 147 | /** |
148 | * package to use. See unzip.h, zip.h and ioapi.h for details. By | ||
149 | * passing NULL (the default) you just tell package to use the | ||
150 | * default API which works just fine on UNIX platforms. I have tried | ||
151 | * it on win32-g++ platform too and it seems it works fine there | ||
152 | * too, so I see no reason to use win32 IO API included in original | ||
153 | * ZIP/UNZIP package. | ||
154 | * | ||
155 | * ZIP archive file name will be converted to 8-bit encoding using | ||
156 | * Qt's QFile::encodeName() function before passing it to the | ||
157 | * ZIP/UNZIP package API. | ||
158 | * | ||
159 | * Returns \c true if successful, \c false otherwise. | ||
160 | * | ||
161 | * Argument \a mode specifies open mode of the ZIP archive. See Mode | 148 | * Argument \a mode specifies open mode of the ZIP archive. See Mode |
162 | * for details. Note that there is zipOpen2() function in the | 149 | * for details. Note that there is zipOpen2() function in the |
163 | * ZIP/UNZIP API which accepts \a globalcomment argument, but it | 150 | * ZIP/UNZIP API which accepts \a globalcomment argument, but it |
164 | * does not use it anywhere, so this open() function does not have this | 151 | * does not use it anywhere, so this open() function does not have this |
165 | * argument. See setComment() if you need to set global comment. | 152 | * argument. See setComment() if you need to set global comment. |
166 | * | 153 | * |
154 | * If the ZIP file is accessed via explicitly set QIODevice, then | ||
155 | * this device is opened in the necessary mode. If the device was | ||
156 | * already opened by some other means, then QuaZIP checks if the | ||
157 | * open mode is compatible to the mode needed for the requested operation. | ||
158 | * If necessary, seeking is performed to position the device properly. | ||
159 | * | ||
160 | * \return \c true if successful, \c false otherwise. | ||
161 | * | ||
167 | * \note ZIP/UNZIP API open calls do not return error code - they | 162 | * \note ZIP/UNZIP API open calls do not return error code - they |
168 | * just return \c NULL indicating an error. But to make things | 163 | * just return \c NULL indicating an error. But to make things |
169 | * easier, quazip.h header defines additional error code \c | 164 | * easier, quazip.h header defines additional error code \c |
170 | * UNZ_ERROROPEN and getZipError() will return it if the open call | 165 | * UNZ_ERROROPEN and getZipError() will return it if the open call |
171 | * of the ZIP/UNZIP API returns \c NULL. | 166 | * of the ZIP/UNZIP API returns \c NULL. |
167 | * | ||
168 | * Argument \a ioApi specifies IO function set for ZIP/UNZIP | ||
169 | * package to use. See unzip.h, zip.h and ioapi.h for details. Note | ||
170 | * that IO API for QuaZip is different from the original package. | ||
171 | * The file path argument was changed to be of type \c voidpf, and | ||
172 | * QuaZip passes a QIODevice pointer there. This QIODevice is either | ||
173 | * set explicitly via setIoDevice() or the QuaZip(QIODevice*) | ||
174 | * constructor, or it is created internally when opening the archive | ||
175 | * by its file name. The default API (qioapi.cpp) just delegates | ||
176 | * everything to the QIODevice API. Not only this allows to use a | ||
177 | * QIODevice instead of file name, but also has a nice side effect | ||
178 | * of raising the file size limit from 2G to 4G (in non-zip64 archives). | ||
179 | * | ||
180 | * \note If the zip64 support is needed, the ioApi argument \em must be NULL | ||
181 | * because due to the backwards compatibility issues it can be used to | ||
182 | * provide a 32-bit API only. | ||
183 | * | ||
184 | * \note If the \ref QuaZip::setAutoClose() "no-auto-close" feature is used, | ||
185 | * then the \a ioApi argument \em should be NULL because the old API | ||
186 | * doesn't support the 'fake close' operation, causing slight memory leaks | ||
187 | * and other possible troubles (like closing the output device in case | ||
188 | * when an error occurs during opening). | ||
189 | * | ||
190 | * In short: just forget about the \a ioApi argument and you'll be | ||
191 | * fine. | ||
172 | **/ | 192 | **/ |
173 | bool open(Mode mode, zlib_filefunc_def *ioApi =NULL); | 193 | bool open(Mode mode, zlib_filefunc_def *ioApi =NULL); |
174 | /// Closes ZIP file. | 194 | /// Closes ZIP file. |
175 | /** Call getZipError() to determine if the close was successful. */ | 195 | /** Call getZipError() to determine if the close was successful. |
196 | * | ||
197 | * If the file was opened by name, then the underlying QIODevice is closed | ||
198 | * and deleted. | ||
199 | * | ||
200 | * If the underlying QIODevice was set explicitly using setIoDevice() or | ||
201 | * the appropriate constructor, then it is closed if the auto-close flag | ||
202 | * is set (which it is by default). Call setAutoClose() to clear the | ||
203 | * auto-close flag if this behavior is undesirable. | ||
204 | * | ||
205 | * Since Qt 5.1, the QSaveFile was introduced. It breaks the QIODevice API | ||
206 | * by making close() private and crashing the application if it is called | ||
207 | * from the base class where it is public. It is an excellent example | ||
208 | * of poor design that illustrates why you should never ever break | ||
209 | * an is-a relationship between the base class and a subclass. QuaZIP | ||
210 | * works around this bug by checking if the QIODevice is an instance | ||
211 | * of QSaveFile, using qobject_cast<>, and if it is, calls | ||
212 | * QSaveFile::commit() instead of close(). It is a really ugly hack, | ||
213 | * but at least it makes your programs work instead of crashing. Note that | ||
214 | * if the auto-close flag is cleared, then this is a non-issue, and | ||
215 | * commit() isn't called. | ||
216 | */ | ||
176 | void close(); | 217 | void close(); |
177 | /// Sets the codec used to encode/decode file names inside archive. | 218 | /// Sets the codec used to encode/decode file names inside archive. |
178 | /** This is necessary to access files in the ZIP archive created | 219 | /** This is necessary to access files in the ZIP archive created |
@@ -180,44 +221,56 @@ class QuaZip { | |||
180 | * example, file names with cyrillic letters will be in \c IBM866 | 221 | * example, file names with cyrillic letters will be in \c IBM866 |
181 | * encoding. | 222 | * encoding. |
182 | **/ | 223 | **/ |
183 | void setFileNameCodec(QTextCodec *fileNameCodec) | 224 | void setFileNameCodec(QTextCodec *fileNameCodec); |
184 | {this->fileNameCodec=fileNameCodec;} | ||
185 | /// Sets the codec used to encode/decode file names inside archive. | 225 | /// Sets the codec used to encode/decode file names inside archive. |
186 | /** \overload | 226 | /** \overload |
187 | * Equivalent to calling setFileNameCodec(QTextCodec::codecForName(codecName)); | 227 | * Equivalent to calling setFileNameCodec(QTextCodec::codecForName(codecName)); |
188 | **/ | 228 | **/ |
189 | void setFileNameCodec(const char *fileNameCodecName) | 229 | void setFileNameCodec(const char *fileNameCodecName); |
190 | {fileNameCodec=QTextCodec::codecForName(fileNameCodecName);} | ||
191 | /// Returns the codec used to encode/decode comments inside archive. | 230 | /// Returns the codec used to encode/decode comments inside archive. |
192 | QTextCodec* getFileNameCodec()const {return fileNameCodec;} | 231 | QTextCodec* getFileNameCodec() const; |
193 | /// Sets the codec used to encode/decode comments inside archive. | 232 | /// Sets the codec used to encode/decode comments inside archive. |
194 | /** This codec defaults to locale codec, which is probably ok. | 233 | /** This codec defaults to locale codec, which is probably ok. |
195 | **/ | 234 | **/ |
196 | void setCommentCodec(QTextCodec *commentCodec) | 235 | void setCommentCodec(QTextCodec *commentCodec); |
197 | {this->commentCodec=commentCodec;} | ||
198 | /// Sets the codec used to encode/decode comments inside archive. | 236 | /// Sets the codec used to encode/decode comments inside archive. |
199 | /** \overload | 237 | /** \overload |
200 | * Equivalent to calling setCommentCodec(QTextCodec::codecForName(codecName)); | 238 | * Equivalent to calling setCommentCodec(QTextCodec::codecForName(codecName)); |
201 | **/ | 239 | **/ |
202 | void setCommentCodec(const char *commentCodecName) | 240 | void setCommentCodec(const char *commentCodecName); |
203 | {commentCodec=QTextCodec::codecForName(commentCodecName);} | ||
204 | /// Returns the codec used to encode/decode comments inside archive. | 241 | /// Returns the codec used to encode/decode comments inside archive. |
205 | QTextCodec* getCommentCodec()const {return commentCodec;} | 242 | QTextCodec* getCommentCodec() const; |
206 | /// Returns the name of the ZIP file. | 243 | /// Returns the name of the ZIP file. |
207 | /** Returns null string if no ZIP file name has been set. | 244 | /** Returns null string if no ZIP file name has been set, for |
208 | * \sa setZipName() | 245 | * example when the QuaZip instance is set up to use a QIODevice |
246 | * instead. | ||
247 | * \sa setZipName(), setIoDevice(), getIoDevice() | ||
209 | **/ | 248 | **/ |
210 | QString getZipName()const {return zipName;} | 249 | QString getZipName() const; |
211 | /// Sets the name of the ZIP file. | 250 | /// Sets the name of the ZIP file. |
212 | /** Does nothing if the ZIP file is open. | 251 | /** Does nothing if the ZIP file is open. |
213 | * | 252 | * |
214 | * Does not reset error code returned by getZipError(). | 253 | * Does not reset error code returned by getZipError(). |
254 | * \sa setIoDevice(), getIoDevice(), getZipName() | ||
215 | **/ | 255 | **/ |
216 | void setZipName(const QString& zipName); | 256 | void setZipName(const QString& zipName); |
257 | /// Returns the device representing this ZIP file. | ||
258 | /** Returns null string if no device has been set explicitly, for | ||
259 | * example when opening a ZIP file by name. | ||
260 | * \sa setIoDevice(), getZipName(), setZipName() | ||
261 | **/ | ||
262 | QIODevice *getIoDevice() const; | ||
263 | /// Sets the device representing the ZIP file. | ||
264 | /** Does nothing if the ZIP file is open. | ||
265 | * | ||
266 | * Does not reset error code returned by getZipError(). | ||
267 | * \sa getIoDevice(), getZipName(), setZipName() | ||
268 | **/ | ||
269 | void setIoDevice(QIODevice *ioDevice); | ||
217 | /// Returns the mode in which ZIP file was opened. | 270 | /// Returns the mode in which ZIP file was opened. |
218 | Mode getMode()const {return mode;} | 271 | Mode getMode() const; |
219 | /// Returns \c true if ZIP file is open, \c false otherwise. | 272 | /// Returns \c true if ZIP file is open, \c false otherwise. |
220 | bool isOpen()const {return mode!=mdNotOpen;} | 273 | bool isOpen() const; |
221 | /// Returns the error code of the last operation. | 274 | /// Returns the error code of the last operation. |
222 | /** Returns \c UNZ_OK if the last operation was successful. | 275 | /** Returns \c UNZ_OK if the last operation was successful. |
223 | * | 276 | * |
@@ -227,20 +280,24 @@ class QuaZip { | |||
227 | * error code too. See documentation for the specific functions for | 280 | * error code too. See documentation for the specific functions for |
228 | * details on error detection. | 281 | * details on error detection. |
229 | **/ | 282 | **/ |
230 | int getZipError()const {return zipError;} | 283 | int getZipError() const; |
231 | /// Returns number of the entries in the ZIP central directory. | 284 | /// Returns number of the entries in the ZIP central directory. |
232 | /** Returns negative error code in the case of error. The same error | 285 | /** Returns negative error code in the case of error. The same error |
233 | * code will be returned by subsequent getZipError() call. | 286 | * code will be returned by subsequent getZipError() call. |
234 | **/ | 287 | **/ |
235 | int getEntriesCount()const; | 288 | int getEntriesCount() const; |
236 | /// Returns global comment in the ZIP file. | 289 | /// Returns global comment in the ZIP file. |
237 | QString getComment()const; | 290 | QString getComment() const; |
238 | /// Sets global comment in the ZIP file. | 291 | /// Sets the global comment in the ZIP file. |
239 | /** Comment will be written to the archive on close operation. | 292 | /** The comment will be written to the archive on close operation. |
293 | * QuaZip makes a distinction between a null QByteArray() comment | ||
294 | * and an empty "" comment in the QuaZip::mdAdd mode. | ||
295 | * A null comment is the default and it means "don't change | ||
296 | * the comment". An empty comment removes the original comment. | ||
240 | * | 297 | * |
241 | * \sa open() | 298 | * \sa open() |
242 | **/ | 299 | **/ |
243 | void setComment(const QString& comment) {this->comment=comment;} | 300 | void setComment(const QString& comment); |
244 | /// Sets the current file to the first file in the archive. | 301 | /// Sets the current file to the first file in the archive. |
245 | /** Returns \c true on success, \c false otherwise. Call | 302 | /** Returns \c true on success, \c false otherwise. Call |
246 | * getZipError() to get the error code. | 303 | * getZipError() to get the error code. |
@@ -292,7 +349,7 @@ class QuaZip { | |||
292 | **/ | 349 | **/ |
293 | bool setCurrentFile(const QString& fileName, CaseSensitivity cs =csDefault); | 350 | bool setCurrentFile(const QString& fileName, CaseSensitivity cs =csDefault); |
294 | /// Returns \c true if the current file has been set. | 351 | /// Returns \c true if the current file has been set. |
295 | bool hasCurrentFile()const {return hasCurrentFile_f;} | 352 | bool hasCurrentFile() const; |
296 | /// Retrieves information about the current file. | 353 | /// Retrieves information about the current file. |
297 | /** Fills the structure pointed by \a info. Returns \c true on | 354 | /** Fills the structure pointed by \a info. Returns \c true on |
298 | * success, \c false otherwise. In the latter case structure pointed | 355 | * success, \c false otherwise. In the latter case structure pointed |
@@ -303,13 +360,29 @@ class QuaZip { | |||
303 | * | 360 | * |
304 | * Does nothing and returns \c false in any of the following cases. | 361 | * Does nothing and returns \c false in any of the following cases. |
305 | * - ZIP is not open; | 362 | * - ZIP is not open; |
306 | * - ZIP does not have current file; | 363 | * - ZIP does not have current file. |
307 | * - \a info is \c NULL; | ||
308 | * | 364 | * |
309 | * In all these cases getZipError() returns \c UNZ_OK since there | 365 | * In both cases getZipError() returns \c UNZ_OK since there |
310 | * is no ZIP/UNZIP API call. | 366 | * is no ZIP/UNZIP API call. |
367 | * | ||
368 | * This overload doesn't support zip64, but will work OK on zip64 archives | ||
369 | * except that if one of the sizes (compressed or uncompressed) is greater | ||
370 | * than 0xFFFFFFFFu, it will be set to exactly 0xFFFFFFFFu. | ||
371 | * | ||
372 | * \sa getCurrentFileInfo(QuaZipFileInfo64* info)const | ||
373 | * \sa QuaZipFileInfo64::toQuaZipFileInfo(QuaZipFileInfo&)const | ||
311 | **/ | 374 | **/ |
312 | bool getCurrentFileInfo(QuaZipFileInfo* info)const; | 375 | bool getCurrentFileInfo(QuaZipFileInfo* info)const; |
376 | /// Retrieves information about the current file. | ||
377 | /** \overload | ||
378 | * | ||
379 | * This function supports zip64. If the archive doesn't use zip64, it is | ||
380 | * completely equivalent to getCurrentFileInfo(QuaZipFileInfo* info) | ||
381 | * except for the argument type. | ||
382 | * | ||
383 | * \sa | ||
384 | **/ | ||
385 | bool getCurrentFileInfo(QuaZipFileInfo64* info)const; | ||
313 | /// Returns the current file name. | 386 | /// Returns the current file name. |
314 | /** Equivalent to calling getCurrentFileInfo() and then getting \c | 387 | /** Equivalent to calling getCurrentFileInfo() and then getting \c |
315 | * name field of the QuaZipFileInfo structure, but faster and more | 388 | * name field of the QuaZipFileInfo structure, but faster and more |
@@ -334,13 +407,165 @@ class QuaZip { | |||
334 | * file in the ZIP archive - then change it back or you may | 407 | * file in the ZIP archive - then change it back or you may |
335 | * experience some strange behavior or even crashes. | 408 | * experience some strange behavior or even crashes. |
336 | **/ | 409 | **/ |
337 | unzFile getUnzFile() {return unzFile_f;} | 410 | unzFile getUnzFile(); |
338 | /// Returns \c zipFile handle. | 411 | /// Returns \c zipFile handle. |
339 | /** You can use this handle to directly call ZIP part of the | 412 | /** You can use this handle to directly call ZIP part of the |
340 | * ZIP/UNZIP package functions (see zip.h). Warnings about the | 413 | * ZIP/UNZIP package functions (see zip.h). Warnings about the |
341 | * getUnzFile() function also apply to this function. | 414 | * getUnzFile() function also apply to this function. |
342 | **/ | 415 | **/ |
343 | zipFile getZipFile() {return zipFile_f;} | 416 | zipFile getZipFile(); |
417 | /// Changes the data descriptor writing mode. | ||
418 | /** | ||
419 | According to the ZIP format specification, a file inside archive | ||
420 | may have a data descriptor immediately following the file | ||
421 | data. This is reflected by a special flag in the local file header | ||
422 | and in the central directory. By default, QuaZIP sets this flag | ||
423 | and writes the data descriptor unless both method and level were | ||
424 | set to 0, in which case it operates in 1.0-compatible mode and | ||
425 | never writes data descriptors. | ||
426 | |||
427 | By setting this flag to false, it is possible to disable data | ||
428 | descriptor writing, thus increasing compatibility with archive | ||
429 | readers that don't understand this feature of the ZIP file format. | ||
430 | |||
431 | Setting this flag affects all the QuaZipFile instances that are | ||
432 | opened after this flag is set. | ||
433 | |||
434 | The data descriptor writing mode is enabled by default. | ||
435 | |||
436 | Note that if the ZIP archive is written into a QIODevice for which | ||
437 | QIODevice::isSequential() returns \c true, then the data descriptor | ||
438 | is mandatory and will be written even if this flag is set to false. | ||
439 | |||
440 | \param enabled If \c true, enable local descriptor writing, | ||
441 | disable it otherwise. | ||
442 | |||
443 | \sa QuaZipFile::isDataDescriptorWritingEnabled() | ||
444 | */ | ||
445 | void setDataDescriptorWritingEnabled(bool enabled); | ||
446 | /// Returns the data descriptor default writing mode. | ||
447 | /** | ||
448 | \sa setDataDescriptorWritingEnabled() | ||
449 | */ | ||
450 | bool isDataDescriptorWritingEnabled() const; | ||
451 | /// Returns a list of files inside the archive. | ||
452 | /** | ||
453 | \return A list of file names or an empty list if there | ||
454 | was an error or if the archive is empty (call getZipError() to | ||
455 | figure out which). | ||
456 | \sa getFileInfoList() | ||
457 | */ | ||
458 | QStringList getFileNameList() const; | ||
459 | /// Returns information list about all files inside the archive. | ||
460 | /** | ||
461 | \return A list of QuaZipFileInfo objects or an empty list if there | ||
462 | was an error or if the archive is empty (call getZipError() to | ||
463 | figure out which). | ||
464 | |||
465 | This function doesn't support zip64, but will still work with zip64 | ||
466 | archives, converting results using QuaZipFileInfo64::toQuaZipFileInfo(). | ||
467 | If all file sizes are below 4 GB, it will work just fine. | ||
468 | |||
469 | \sa getFileNameList() | ||
470 | \sa getFileInfoList64() | ||
471 | */ | ||
472 | QList<QuaZipFileInfo> getFileInfoList() const; | ||
473 | /// Returns information list about all files inside the archive. | ||
474 | /** | ||
475 | \overload | ||
476 | |||
477 | This function supports zip64. | ||
478 | |||
479 | \sa getFileNameList() | ||
480 | \sa getFileInfoList() | ||
481 | */ | ||
482 | QList<QuaZipFileInfo64> getFileInfoList64() const; | ||
483 | /// Enables the zip64 mode. | ||
484 | /** | ||
485 | * @param zip64 If \c true, the zip64 mode is enabled, disabled otherwise. | ||
486 | * | ||
487 | * Once this is enabled, all new files (until the mode is disabled again) | ||
488 | * will be created in the zip64 mode, thus enabling the ability to write | ||
489 | * files larger than 4 GB. By default, the zip64 mode is off due to | ||
490 | * compatibility reasons. | ||
491 | * | ||
492 | * Note that this does not affect the ability to read zip64 archives in any | ||
493 | * way. | ||
494 | * | ||
495 | * \sa isZip64Enabled() | ||
496 | */ | ||
497 | void setZip64Enabled(bool zip64); | ||
498 | /// Returns whether the zip64 mode is enabled. | ||
499 | /** | ||
500 | * @return \c true if and only if the zip64 mode is enabled. | ||
501 | * | ||
502 | * \sa setZip64Enabled() | ||
503 | */ | ||
504 | bool isZip64Enabled() const; | ||
505 | /// Returns the auto-close flag. | ||
506 | /** | ||
507 | @sa setAutoClose() | ||
508 | */ | ||
509 | bool isAutoClose() const; | ||
510 | /// Sets or unsets the auto-close flag. | ||
511 | /** | ||
512 | By default, QuaZIP opens the underlying QIODevice when open() is called, | ||
513 | and closes it when close() is called. In some cases, when the device | ||
514 | is set explicitly using setIoDevice(), it may be desirable to | ||
515 | leave the device open. If the auto-close flag is unset using this method, | ||
516 | then the device isn't closed automatically if it was set explicitly. | ||
517 | |||
518 | If it is needed to clear this flag, it is recommended to do so before | ||
519 | opening the archive because otherwise QuaZIP may close the device | ||
520 | during the open() call if an error is encountered after the device | ||
521 | is opened. | ||
522 | |||
523 | If the device was not set explicitly, but rather the setZipName() or | ||
524 | the appropriate constructor was used to set the ZIP file name instead, | ||
525 | then the auto-close flag has no effect, and the internal device | ||
526 | is closed nevertheless because there is no other way to close it. | ||
527 | |||
528 | @sa isAutoClose() | ||
529 | @sa setIoDevice() | ||
530 | */ | ||
531 | void setAutoClose(bool autoClose) const; | ||
532 | /// Sets the default file name codec to use. | ||
533 | /** | ||
534 | * The default codec is used by the constructors, so calling this function | ||
535 | * won't affect the QuaZip instances already created at that moment. | ||
536 | * | ||
537 | * The codec specified here can be overriden by calling setFileNameCodec(). | ||
538 | * If neither function is called, QTextCodec::codecForLocale() will be used | ||
539 | * to decode or encode file names. Use this function with caution if | ||
540 | * the application uses other libraries that depend on QuaZIP. Those | ||
541 | * libraries can either call this function by themselves, thus overriding | ||
542 | * your setting or can rely on the default encoding, thus failing | ||
543 | * mysteriously if you change it. For these reasons, it isn't recommended | ||
544 | * to use this function if you are developing a library, not an application. | ||
545 | * Instead, ask your library users to call it in case they need specific | ||
546 | * encoding. | ||
547 | * | ||
548 | * In most cases, using setFileNameCodec() instead is the right choice. | ||
549 | * However, if you depend on third-party code that uses QuaZIP, then the | ||
550 | * reasons stated above can actually become a reason to use this function | ||
551 | * in case the third-party code in question fails because it doesn't | ||
552 | * understand the encoding you need and doesn't provide a way to specify it. | ||
553 | * This applies to the JlCompress class as well, as it was contributed and | ||
554 | * doesn't support explicit encoding parameters. | ||
555 | * | ||
556 | * In short: use setFileNameCodec() when you can, resort to | ||
557 | * setDefaultFileNameCodec() when you don't have access to the QuaZip | ||
558 | * instance. | ||
559 | * | ||
560 | * @param codec The codec to use by default. If NULL, resets to default. | ||
561 | */ | ||
562 | static void setDefaultFileNameCodec(QTextCodec *codec); | ||
563 | /** | ||
564 | * @overload | ||
565 | * Equivalent to calling | ||
566 | * setDefltFileNameCodec(QTextCodec::codecForName(codecName)). | ||
567 | */ | ||
568 | static void setDefaultFileNameCodec(const char *codecName); | ||
344 | }; | 569 | }; |
345 | 570 | ||
346 | #endif | 571 | #endif |