summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/quazip/quazipfile.h
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2015-03-08 19:07:42 +0100
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2015-05-02 16:52:14 +0200
commitb230cf3aa24f3883b8b165bd5fd56620a9a95e47 (patch)
tree19e46e3697c98c3e51f7f4e91e3879f95bd0bc43 /rbutil/rbutilqt/quazip/quazipfile.h
parentd4fee369712f006785fd3a8904a5e2b5c529598b (diff)
downloadrockbox-b230cf3aa24f3883b8b165bd5fd56620a9a95e47.tar.gz
rockbox-b230cf3aa24f3883b8b165bd5fd56620a9a95e47.zip
Update quazip to release 0.7.1.
Update to latest quazip release. Note that quazip is now LGPL and not GPL / LGPL dual licensed anymore. Change-Id: Ie1e975b5b546dd31218eef9df472527493fe81e0
Diffstat (limited to 'rbutil/rbutilqt/quazip/quazipfile.h')
-rw-r--r--rbutil/rbutilqt/quazip/quazipfile.h114
1 files changed, 64 insertions, 50 deletions
diff --git a/rbutil/rbutilqt/quazip/quazipfile.h b/rbutil/rbutilqt/quazip/quazipfile.h
index 09af5bceca..e27b7a4a6c 100644
--- a/rbutil/rbutilqt/quazip/quazipfile.h
+++ b/rbutil/rbutilqt/quazip/quazipfile.h
@@ -2,42 +2,37 @@
2#define QUA_ZIPFILE_H 2#define QUA_ZIPFILE_H
3 3
4/* 4/*
5-- A kind of "standard" GPL license statement -- 5Copyright (C) 2005-2014 Sergey A. Tachenov
6QuaZIP - a Qt/C++ wrapper for the ZIP/UNZIP package
7Copyright (C) 2005-2008 Sergey A. Tachenov
8 6
9This program is free software; you can redistribute it and/or modify it 7This file is part of QuaZIP.
10under the terms of the GNU General Public License as published by the
11Free Software Foundation; either version 2 of the License, or (at your
12option) any later version.
13 8
14This program is distributed in the hope that it will be useful, but 9QuaZIP is free software: you can redistribute it and/or modify
15WITHOUT ANY WARRANTY; without even the implied warranty of 10it under the terms of the GNU Lesser General Public License as published by
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 11the Free Software Foundation, either version 2.1 of the License, or
17Public License for more details. 12(at your option) any later version.
18 13
19You should have received a copy of the GNU General Public License along 14QuaZIP is distributed in the hope that it will be useful,
20with this program; if not, write to the Free Software Foundation, Inc., 15but WITHOUT ANY WARRANTY; without even the implied warranty of
2159 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU Lesser General Public License for more details.
22 18
23-- A kind of "standard" GPL license statement ends here -- 19You should have received a copy of the GNU Lesser General Public License
20along with QuaZIP. If not, see <http://www.gnu.org/licenses/>.
24 21
25See COPYING file for GPL. 22See COPYING file for the full LGPL text.
26 23
27You are also permitted to use QuaZIP under the terms of LGPL (see 24Original ZIP package is copyrighted by Gilles Vollant, see
28COPYING.LGPL). You are free to choose either license, but please note 25quazip/(un)zip.h files for details, basically it's zlib license.
29that QuaZIP makes use of Qt, which is not licensed under LGPL. So if
30you are using Open Source edition of Qt, you therefore MUST use GPL for
31your code based on QuaZIP, since it would be also based on Qt in this
32case. If you are Qt commercial license owner, then you are free to use
33QuaZIP as long as you respect either GPL or LGPL for QuaZIP code.
34 **/ 26 **/
35 27
36#include <QIODevice> 28#include <QIODevice>
37 29
30#include "quazip_global.h"
38#include "quazip.h" 31#include "quazip.h"
39#include "quazipnewinfo.h" 32#include "quazipnewinfo.h"
40 33
34class QuaZipFilePrivate;
35
41/// A file inside ZIP archive. 36/// A file inside ZIP archive.
42/** \class QuaZipFile quazipfile.h <quazip/quazipfile.h> 37/** \class QuaZipFile quazipfile.h <quazip/quazipfile.h>
43 * This is the most interesting class. Not only it provides C++ 38 * This is the most interesting class. Not only it provides C++
@@ -51,6 +46,14 @@ QuaZIP as long as you respect either GPL or LGPL for QuaZIP code.
51 * it will create internal QuaZip object. See constructors' descriptions 46 * it will create internal QuaZip object. See constructors' descriptions
52 * for details. Writing is only possible with the existing instance. 47 * for details. Writing is only possible with the existing instance.
53 * 48 *
49 * Note that due to the underlying library's limitation it is not
50 * possible to use multiple QuaZipFile instances to open several files
51 * in the same archive at the same time. If you need to write to
52 * multiple files in parallel, then you should write to temporary files
53 * first, then pack them all at once when you have finished writing. If
54 * you need to read multiple files inside the same archive in parallel,
55 * you should extract them all into a temporary directory first.
56 *
54 * \section quazipfile-sequential Sequential or random-access? 57 * \section quazipfile-sequential Sequential or random-access?
55 * 58 *
56 * At the first thought, QuaZipFile has fixed size, the start and the 59 * At the first thought, QuaZipFile has fixed size, the start and the
@@ -58,7 +61,7 @@ QuaZIP as long as you respect either GPL or LGPL for QuaZIP code.
58 * there is one major obstacle to making it random-access: ZIP/UNZIP API 61 * there is one major obstacle to making it random-access: ZIP/UNZIP API
59 * does not support seek() operation and the only way to implement it is 62 * does not support seek() operation and the only way to implement it is
60 * through reopening the file and re-reading to the required position, 63 * through reopening the file and re-reading to the required position,
61 * but this is prohibitely slow. 64 * but this is prohibitively slow.
62 * 65 *
63 * Therefore, QuaZipFile is considered to be a sequential device. This 66 * Therefore, QuaZipFile is considered to be a sequential device. This
64 * has advantage of availability of the ungetChar() operation (QIODevice 67 * has advantage of availability of the ungetChar() operation (QIODevice
@@ -68,25 +71,14 @@ QuaZIP as long as you respect either GPL or LGPL for QuaZIP code.
68 * this class. 71 * this class.
69 * 72 *
70 **/ 73 **/
71class QuaZipFile: public QIODevice { 74class QUAZIP_EXPORT QuaZipFile: public QIODevice {
75 friend class QuaZipFilePrivate;
72 Q_OBJECT 76 Q_OBJECT
73 private: 77 private:
74 QuaZip *zip; 78 QuaZipFilePrivate *p;
75 QString fileName;
76 QuaZip::CaseSensitivity caseSensitivity;
77 bool raw;
78 qint64 writePos;
79 // these two are for writing raw files
80 ulong uncompressedSize;
81 quint32 crc;
82 bool internal;
83 int zipError;
84 // these are not supported nor implemented 79 // these are not supported nor implemented
85 QuaZipFile(const QuaZipFile& that); 80 QuaZipFile(const QuaZipFile& that);
86 QuaZipFile& operator=(const QuaZipFile& that); 81 QuaZipFile& operator=(const QuaZipFile& that);
87 void resetZipError()const {setZipError(UNZ_OK);}
88 // const, but sets zipError!
89 void setZipError(int zipError)const;
90 protected: 82 protected:
91 /// Implementation of the QIODevice::readData(). 83 /// Implementation of the QIODevice::readData().
92 qint64 readData(char *data, qint64 maxSize); 84 qint64 readData(char *data, qint64 maxSize);
@@ -212,7 +204,7 @@ class QuaZipFile: public QIODevice {
212 * 204 *
213 * \sa getActualFileName 205 * \sa getActualFileName
214 **/ 206 **/
215 QString getFileName()const {return fileName;} 207 QString getFileName() const;
216 /// Returns case sensitivity of the file name. 208 /// Returns case sensitivity of the file name.
217 /** This function returns case sensitivity argument you passed to 209 /** This function returns case sensitivity argument you passed to
218 * this object either by using 210 * this object either by using
@@ -225,7 +217,7 @@ class QuaZipFile: public QIODevice {
225 * 217 *
226 * \sa getFileName 218 * \sa getFileName
227 **/ 219 **/
228 QuaZip::CaseSensitivity getCaseSensitivity()const {return caseSensitivity;} 220 QuaZip::CaseSensitivity getCaseSensitivity() const;
229 /// Returns the actual file name in the archive. 221 /// Returns the actual file name in the archive.
230 /** This is \em not a ZIP archive file name, but a name of file inside 222 /** This is \em not a ZIP archive file name, but a name of file inside
231 * archive. It is not necessary the same name that you have passed 223 * archive. It is not necessary the same name that you have passed
@@ -265,7 +257,7 @@ class QuaZipFile: public QIODevice {
265 * 257 *
266 * \sa open(OpenMode,int*,int*,bool,const char*) 258 * \sa open(OpenMode,int*,int*,bool,const char*)
267 **/ 259 **/
268 bool isRaw()const {return raw;} 260 bool isRaw() const;
269 /// Binds to the existing QuaZip instance. 261 /// Binds to the existing QuaZip instance.
270 /** This function destroys internal QuaZip object, if any, and makes 262 /** This function destroys internal QuaZip object, if any, and makes
271 * this QuaZipFile to use current file in the \a zip object for any 263 * this QuaZipFile to use current file in the \a zip object for any
@@ -303,7 +295,7 @@ class QuaZipFile: public QIODevice {
303 * Argument \a password specifies a password to decrypt the file. If 295 * Argument \a password specifies a password to decrypt the file. If
304 * it is NULL then this function behaves just like open(OpenMode). 296 * it is NULL then this function behaves just like open(OpenMode).
305 **/ 297 **/
306 bool open(OpenMode mode, const char *password) 298 inline bool open(OpenMode mode, const char *password)
307 {return open(mode, NULL, NULL, false, password);} 299 {return open(mode, NULL, NULL, false, password);}
308 /// Opens a file for reading. 300 /// Opens a file for reading.
309 /** \overload 301 /** \overload
@@ -324,14 +316,21 @@ class QuaZipFile: public QIODevice {
324 * specify correct timestamp (by default, current time will be 316 * specify correct timestamp (by default, current time will be
325 * used). See QuaZipNewInfo. 317 * used). See QuaZipNewInfo.
326 * 318 *
327 * Arguments \a password and \a crc provide necessary information 319 * The \a password argument specifies the password for crypting. Pass NULL
328 * for crypting. Note that you should specify both of them if you 320 * if you don't need any crypting. The \a crc argument was supposed
329 * need crypting. If you do not, pass \c NULL as password, but you 321 * to be used for crypting too, but then it turned out that it's
330 * still need to specify \a crc if you are going to use raw mode 322 * false information, so you need to set it to 0 unless you want to
331 * (see below). 323 * use the raw mode (see below).
332 * 324 *
333 * Arguments \a method and \a level specify compression method and 325 * Arguments \a method and \a level specify compression method and
334 * level. 326 * level. The only method supported is Z_DEFLATED, but you may also
327 * specify 0 for no compression. If all of the files in the archive
328 * use both method 0 and either level 0 is explicitly specified or
329 * data descriptor writing is disabled with
330 * QuaZip::setDataDescriptorWritingEnabled(), then the
331 * resulting archive is supposed to be compatible with the 1.0 ZIP
332 * format version, should you need that. Except for this, \a level
333 * has no other effects with method 0.
335 * 334 *
336 * If \a raw is \c true, no compression is performed. In this case, 335 * If \a raw is \c true, no compression is performed. In this case,
337 * \a crc and uncompressedSize field of the \a info are required. 336 * \a crc and uncompressedSize field of the \a info are required.
@@ -428,15 +427,30 @@ class QuaZipFile: public QIODevice {
428 * 427 *
429 * File must be open for reading before calling this function. 428 * File must be open for reading before calling this function.
430 * 429 *
431 * Returns \c false in the case of an error. 430 * \return \c false in the case of an error.
431 *
432 * This function doesn't support zip64, but will still work fine on zip64
433 * archives if file sizes are below 4 GB, otherwise the values will be set
434 * as if converted using QuaZipFileInfo64::toQuaZipFileInfo().
435 *
436 * \sa getFileInfo(QuaZipFileInfo64*)
432 **/ 437 **/
433 bool getFileInfo(QuaZipFileInfo *info); 438 bool getFileInfo(QuaZipFileInfo *info);
439 /// Gets information about current file with zip64 support.
440 /**
441 * @overload
442 *
443 * \sa getFileInfo(QuaZipFileInfo*)
444 */
445 bool getFileInfo(QuaZipFileInfo64 *info);
434 /// Closes the file. 446 /// Closes the file.
435 /** Call getZipError() to determine if the close was successful. 447 /** Call getZipError() to determine if the close was successful.
436 **/ 448 **/
437 virtual void close(); 449 virtual void close();
438 /// Returns the error code returned by the last ZIP/UNZIP API call. 450 /// Returns the error code returned by the last ZIP/UNZIP API call.
439 int getZipError()const {return zipError;} 451 int getZipError() const;
452 /// Returns the number of bytes available for reading.
453 virtual qint64 bytesAvailable() const;
440}; 454};
441 455
442#endif 456#endif