ckb-next  v0.2.8 at branch master
ckb-next driver for corsair devices
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
QuaZipFile Class Reference

A file inside ZIP archive. More...

#include <quazip/quazipfile.h>

+ Inheritance diagram for QuaZipFile:
+ Collaboration diagram for QuaZipFile:

Public Member Functions

 QuaZipFile ()
 Constructs a QuaZipFile instance. More...
 
 QuaZipFile (QObject *parent)
 Constructs a QuaZipFile instance. More...
 
 QuaZipFile (const QString &zipName, QObject *parent=NULL)
 Constructs a QuaZipFile instance. More...
 
 QuaZipFile (const QString &zipName, const QString &fileName, QuaZip::CaseSensitivity cs=QuaZip::csDefault, QObject *parent=NULL)
 Constructs a QuaZipFile instance. More...
 
 QuaZipFile (QuaZip *zip, QObject *parent=NULL)
 Constructs a QuaZipFile instance. More...
 
virtual ~QuaZipFile ()
 Destroys a QuaZipFile instance. More...
 
QString getZipName () const
 Returns the ZIP archive file name. More...
 
QuaZipgetZip () const
 Returns a pointer to the associated QuaZip object. More...
 
QString getFileName () const
 Returns file name. More...
 
QuaZip::CaseSensitivity getCaseSensitivity () const
 Returns case sensitivity of the file name. More...
 
QString getActualFileName () const
 Returns the actual file name in the archive. More...
 
void setZipName (const QString &zipName)
 Sets the ZIP archive file name. More...
 
bool isRaw () const
 Returns true if the file was opened in raw mode. More...
 
void setZip (QuaZip *zip)
 Binds to the existing QuaZip instance. More...
 
void setFileName (const QString &fileName, QuaZip::CaseSensitivity cs=QuaZip::csDefault)
 Sets the file name. More...
 
virtual bool open (OpenMode mode)
 Opens a file for reading. More...
 
bool open (OpenMode mode, const char *password)
 Opens a file for reading. More...
 
bool open (OpenMode mode, int *method, int *level, bool raw, const char *password=NULL)
 Opens a file for reading. More...
 
bool open (OpenMode mode, const QuaZipNewInfo &info, const char *password=NULL, quint32 crc=0, int method=Z_DEFLATED, int level=Z_DEFAULT_COMPRESSION, bool raw=false, int windowBits=-MAX_WBITS, int memLevel=MAX_MEM_LEVEL, int strategy=Z_DEFAULT_STRATEGY)
 Opens a file for writing. More...
 
virtual bool isSequential () const
 Returns true, but beware! More...
 
virtual qint64 pos () const
 Returns current position in the file. More...
 
virtual bool atEnd () const
 Returns true if the end of file was reached. More...
 
virtual qint64 size () const
 Returns file size. More...
 
qint64 csize () const
 Returns compressed file size. More...
 
qint64 usize () const
 Returns uncompressed file size. More...
 
bool getFileInfo (QuaZipFileInfo *info)
 Gets information about current file. More...
 
bool getFileInfo (QuaZipFileInfo64 *info)
 Gets information about current file with zip64 support. More...
 
virtual void close ()
 Closes the file. More...
 
int getZipError () const
 Returns the error code returned by the last ZIP/UNZIP API call. More...
 
virtual qint64 bytesAvailable () const
 Returns the number of bytes available for reading. More...
 

Protected Member Functions

qint64 readData (char *data, qint64 maxSize)
 Implementation of the QIODevice::readData(). More...
 
qint64 writeData (const char *data, qint64 maxSize)
 Implementation of the QIODevice::writeData(). More...
 

Private Member Functions

 QuaZipFile (const QuaZipFile &that)
 
QuaZipFileoperator= (const QuaZipFile &that)
 

Private Attributes

QuaZipFilePrivatep
 

Friends

class QuaZipFilePrivate
 

Detailed Description

This is the most interesting class. Not only it provides C++ interface to the ZIP/UNZIP package, but also integrates it with Qt by subclassing QIODevice. This makes possible to access files inside ZIP archive using QTextStream or QDataStream, for example. Actually, this is the main purpose of the whole QuaZIP library.

You can either use existing QuaZip instance to create instance of this class or pass ZIP archive file name to this class, in which case it will create internal QuaZip object. See constructors' descriptions for details. Writing is only possible with the existing instance.

Note that due to the underlying library's limitation it is not possible to use multiple QuaZipFile instances to open several files in the same archive at the same time. If you need to write to multiple files in parallel, then you should write to temporary files first, then pack them all at once when you have finished writing. If you need to read multiple files inside the same archive in parallel, you should extract them all into a temporary directory first.

Sequential or random-access?

At the first thought, QuaZipFile has fixed size, the start and the end and should be therefore considered random-access device. But there is one major obstacle to making it random-access: ZIP/UNZIP API does not support seek() operation and the only way to implement it is through reopening the file and re-reading to the required position, but this is prohibitively slow.

Therefore, QuaZipFile is considered to be a sequential device. This has advantage of availability of the ungetChar() operation (QIODevice does not implement it properly for non-sequential devices unless they support seek()). Disadvantage is a somewhat strange behaviour of the size() and pos() functions. This should be kept in mind while using this class.

Definition at line 74 of file quazipfile.h.

Constructor & Destructor Documentation

QuaZipFile::QuaZipFile ( const QuaZipFile that)
private
QuaZipFile::QuaZipFile ( )

You should use setZipName() and setFileName() or setZip() before trying to call open() on the constructed object.

Definition at line 108 of file quazipfile.cpp.

108  :
109  p(new QuaZipFilePrivate(this))
110 {
111 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
friend class QuaZipFilePrivate
Definition: quazipfile.h:75
QuaZipFile::QuaZipFile ( QObject parent)

parent argument specifies this object's parent object.

You should use setZipName() and setFileName() or setZip() before trying to call open() on the constructed object.

Definition at line 113 of file quazipfile.cpp.

113  :
114  QIODevice(parent),
115  p(new QuaZipFilePrivate(this))
116 {
117 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
friend class QuaZipFilePrivate
Definition: quazipfile.h:75
QuaZipFile::QuaZipFile ( const QString &  zipName,
QObject parent = NULL 
)

parent argument specifies this object's parent object and zipName specifies ZIP archive file name.

You should use setFileName() before trying to call open() on the constructed object.

QuaZipFile constructed by this constructor can be used for read only access. Use QuaZipFile(QuaZip*,QObject*) for writing.

Definition at line 119 of file quazipfile.cpp.

119  :
120  QIODevice(parent),
121  p(new QuaZipFilePrivate(this, zipName))
122 {
123 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
friend class QuaZipFilePrivate
Definition: quazipfile.h:75
QuaZipFile::QuaZipFile ( const QString &  zipName,
const QString &  fileName,
QuaZip::CaseSensitivity  cs = QuaZip::csDefault,
QObject parent = NULL 
)

parent argument specifies this object's parent object, zipName specifies ZIP archive file name and fileName and cs specify a name of the file to open inside archive.

QuaZipFile constructed by this constructor can be used for read only access. Use QuaZipFile(QuaZip*,QObject*) for writing.

See Also
QuaZip::setCurrentFile()

Definition at line 125 of file quazipfile.cpp.

126  :
127  QIODevice(parent),
128  p(new QuaZipFilePrivate(this, zipName, fileName, cs))
129 {
130 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
friend class QuaZipFilePrivate
Definition: quazipfile.h:75
QuaZipFile::QuaZipFile ( QuaZip zip,
QObject parent = NULL 
)

parent argument specifies this object's parent object.

zip is the pointer to the existing QuaZip object. This QuaZipFile object then can be used to read current file in the zip or to write to the file inside it.

Warning
Using this constructor for reading current file can be tricky. Let's take the following example:
QuaZip zip("archive.zip");
zip.open(QuaZip::mdUnzip);
zip.setCurrentFile("file-in-archive");
QuaZipFile file(&zip);
file.open(QIODevice::ReadOnly);
// ok, now we can read from the file
file.read(somewhere, some);
zip.setCurrentFile("another-file-in-archive"); // oops...
QuaZipFile anotherFile(&zip);
anotherFile.open(QIODevice::ReadOnly);
anotherFile.read(somewhere, some); // this is still ok...
file.read(somewhere, some); // and this is NOT
So, what exactly happens here? When we change current file in the zip archive, file that references it becomes invalid (actually, as far as I understand ZIP/UNZIP sources, it becomes closed, but QuaZipFile has no means to detect it).

Summary: do not close zip object or change its current file as long as QuaZipFile is open. Even better - use another constructors which create internal QuaZip instances, one per object, and therefore do not cause unnecessary trouble. This constructor may be useful, though, if you already have a QuaZip instance and do not want to access several files at once. Good example:

QuaZip zip("archive.zip");
zip.open(QuaZip::mdUnzip);
// first, we need some information about archive itself
QByteArray comment=zip.getComment();
// and now we are going to access files inside it
QuaZipFile file(&zip);
for(bool more=zip.goToFirstFile(); more; more=zip.goToNextFile()) {
file.open(QIODevice::ReadOnly);
// do something cool with file here
file.close(); // do not forget to close!
}
zip.close();

Definition at line 132 of file quazipfile.cpp.

132  :
133  QIODevice(parent),
134  p(new QuaZipFilePrivate(this, zip))
135 {
136 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
friend class QuaZipFilePrivate
Definition: quazipfile.h:75
QuaZipFile::~QuaZipFile ( )
virtual

Closes file if open, destructs internal QuaZip object (if it exists and is internal, of course).

Definition at line 138 of file quazipfile.cpp.

References close(), and p.

139 {
140  if (isOpen())
141  close();
142  delete p;
143 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
virtual void close()
Closes the file.
Definition: quazipfile.cpp:432

+ Here is the call graph for this function:

Member Function Documentation

bool QuaZipFile::atEnd ( ) const
virtual

This function returns false in the case of error. This means that you called this function on either not open file, or a file in the not open archive or even on a QuaZipFile instance that does not even have QuaZip instance associated. Do not do that because there is no means to determine whether false is returned because of error or because end of file was reached. Well, on the other side you may interpret false return value as "there is no file open to check for end of file and there is no end of file therefore".

When writing, this function always returns true (because you are always writing to the end of file).

Error code returned by getZipError() is not affected by this function call.

Definition at line 361 of file quazipfile.cpp.

References QuaZip::getUnzFile(), p, unzeof(), and QuaZipFilePrivate::zip.

362 {
363  if(p->zip==NULL) {
364  qWarning("QuaZipFile::atEnd(): call setZipName() or setZip() first");
365  return false;
366  }
367  if(!isOpen()) {
368  qWarning("QuaZipFile::atEnd(): file is not open");
369  return false;
370  }
371  if(openMode()&ReadOnly)
372  // the same problem as with pos()
373  return QIODevice::bytesAvailable() == 0
374  && unzeof(p->zip->getUnzFile())==1;
375  else
376  return true;
377 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
int ZEXPORT unzeof(unzFile file)
Definition: unzip.c:1932
unzFile getUnzFile()
Returns unzFile handle.
Definition: quazip.cpp:639
QuaZip * zip
The QuaZip object to work with.
Definition: quazipfile.cpp:43

+ Here is the call graph for this function:

qint64 QuaZipFile::bytesAvailable ( ) const
virtual

Definition at line 499 of file quazipfile.cpp.

References pos(), and size().

500 {
501  return size() - pos();
502 }
virtual qint64 pos() const
Returns current position in the file.
Definition: quazipfile.cpp:342
virtual qint64 size() const
Returns file size.
Definition: quazipfile.cpp:379

+ Here is the call graph for this function:

void QuaZipFile::close ( )
virtual

Call getZipError() to determine if the close was successful.

Definition at line 432 of file quazipfile.cpp.

References QuaZip::close(), QuaZipFilePrivate::crc, QuaZip::getUnzFile(), QuaZip::getZipError(), QuaZip::getZipFile(), QuaZipFilePrivate::internal, QuaZip::isOpen(), isRaw(), p, QuaZipFilePrivate::resetZipError(), QuaZipFilePrivate::setZipError(), QuaZipFilePrivate::uncompressedSize, UNZ_OK, unzCloseCurrentFile(), QuaZipFilePrivate::zip, zipCloseFileInZip(), zipCloseFileInZipRaw64(), and QuaZipFilePrivate::zipError.

Referenced by JlCompress::compressFile(), JlCompress::compressSubDir(), JlCompress::extractFile(), and ~QuaZipFile().

433 {
434  p->resetZipError();
435  if(p->zip==NULL||!p->zip->isOpen()) return;
436  if(!isOpen()) {
437  qWarning("QuaZipFile::close(): file isn't open");
438  return;
439  }
440  if(openMode()&ReadOnly)
442  else if(openMode()&WriteOnly)
445  else {
446  qWarning("Wrong open mode: %d", (int)openMode());
447  return;
448  }
449  if(p->zipError==UNZ_OK) setOpenMode(QIODevice::NotOpen);
450  else return;
451  if(p->internal) {
452  p->zip->close();
453  p->setZipError(p->zip->getZipError());
454  }
455 }
quint32 crc
CRC to write along with a raw file.
Definition: quazipfile.cpp:59
QuaZipFilePrivate * p
Definition: quazipfile.h:78
bool isOpen() const
Returns true if ZIP file is open, false otherwise.
Definition: quazip.cpp:619
int zipError
The last error.
Definition: quazipfile.cpp:67
int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_size, uLong crc32)
Definition: zip.c:1554
#define UNZ_OK
Definition: unzip.h:79
int getZipError() const
Returns the error code of the last operation.
Definition: quazip.cpp:624
void setZipError(int zipError) const
Sets the zip error.
Definition: quazipfile.cpp:211
zipFile getZipFile()
Returns zipFile handle.
Definition: quazip.cpp:644
bool internal
Whether zip points to an internal QuaZip instance.
Definition: quazipfile.cpp:65
int ZEXPORT unzCloseCurrentFile(unzFile file)
Definition: unzip.c:2012
void close()
Closes ZIP file.
Definition: quazip.cpp:324
unzFile getUnzFile()
Returns unzFile handle.
Definition: quazip.cpp:639
QuaZip * zip
The QuaZip object to work with.
Definition: quazipfile.cpp:43
int ZEXPORT zipCloseFileInZip(zipFile file)
Definition: zip.c:1810
quint64 uncompressedSize
Uncompressed size to write along with a raw file.
Definition: quazipfile.cpp:57
bool isRaw() const
Returns true if the file was opened in raw mode.
Definition: quazipfile.cpp:489
void resetZipError() const
Resets zipError.
Definition: quazipfile.cpp:69

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

qint64 QuaZipFile::csize ( ) const

Equivalent to calling getFileInfo() and then getting compressedSize field, but more convenient and faster.

File must be open for reading before calling this function.

Returns -1 on error, call getZipError() to get error code.

Definition at line 391 of file quazipfile.cpp.

References unz_file_info64_s::compressed_size, QuaZip::getMode(), QuaZip::getUnzFile(), QuaZip::mdUnzip, p, QuaZipFilePrivate::setZipError(), UNZ_OK, unzGetCurrentFileInfo64(), QuaZipFilePrivate::zip, and QuaZipFilePrivate::zipError.

Referenced by size().

392 {
393  unz_file_info64 info_z;
394  p->setZipError(UNZ_OK);
395  if(p->zip==NULL||p->zip->getMode()!=QuaZip::mdUnzip) return -1;
396  p->setZipError(unzGetCurrentFileInfo64(p->zip->getUnzFile(), &info_z, NULL, 0, NULL, 0, NULL, 0));
397  if(p->zipError!=UNZ_OK)
398  return -1;
399  return info_z.compressed_size;
400 }
ZPOS64_T compressed_size
Definition: unzip.h:127
QuaZipFilePrivate * p
Definition: quazipfile.h:78
int zipError
The last error.
Definition: quazipfile.cpp:67
#define UNZ_OK
Definition: unzip.h:79
Mode getMode() const
Returns the mode in which ZIP file was opened.
Definition: quazip.cpp:614
void setZipError(int zipError) const
Sets the zip error.
Definition: quazipfile.cpp:211
ZIP file is open for reading files inside it.
Definition: quazip.h:96
int ZEXPORT unzGetCurrentFileInfo64(unzFile file, unz_file_info64 *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
Definition: unzip.c:1134
unzFile getUnzFile()
Returns unzFile handle.
Definition: quazip.cpp:639
QuaZip * zip
The QuaZip object to work with.
Definition: quazipfile.cpp:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

QString QuaZipFile::getActualFileName ( ) const

This is not a ZIP archive file name, but a name of file inside archive. It is not necessary the same name that you have passed to the QuaZipFile(const QString&,const QString&,QuaZip::CaseSensitivity,QObject*), setFileName() or QuaZip::setCurrentFile() - this is the real file name inside archive, so it may differ in case if the file name search was case-insensitive.

Equivalent to calling getCurrentFileName() on the associated QuaZip object. Returns null string if there is no associated QuaZip object or if it does not have a current file yet. And this is the case if you called setFileName() but did not open the file yet. So this is perfectly fine:

QuaZipFile file("somezip.zip");
file.setFileName("somefile");
QString name=file.getName(); // name=="somefile"
QString actual=file.getActualFileName(); // actual is null string
file.open(QIODevice::ReadOnly);
QString actual=file.getActualFileName(); // actual can be "SoMeFiLe" on Windows
See Also
getZipName(), getFileName(), QuaZip::CaseSensitivity

Definition at line 155 of file quazipfile.cpp.

References QuaZip::getCurrentFileName(), QuaZip::getZipError(), p, QuaZipFilePrivate::setZipError(), UNZ_OK, and QuaZipFilePrivate::zip.

156 {
157  p->setZipError(UNZ_OK);
158  if (p->zip == NULL || (openMode() & WriteOnly))
159  return QString();
160  QString name=p->zip->getCurrentFileName();
161  if(name.isNull())
162  p->setZipError(p->zip->getZipError());
163  return name;
164 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
QString getCurrentFileName() const
Returns the current file name.
Definition: quazip.cpp:551
#define UNZ_OK
Definition: unzip.h:79
int getZipError() const
Returns the error code of the last operation.
Definition: quazip.cpp:624
void setZipError(int zipError) const
Sets the zip error.
Definition: quazipfile.cpp:211
QuaZip * zip
The QuaZip object to work with.
Definition: quazipfile.cpp:43

+ Here is the call graph for this function:

QuaZip::CaseSensitivity QuaZipFile::getCaseSensitivity ( ) const

This function returns case sensitivity argument you passed to this object either by using QuaZipFile(const QString&,const QString&,QuaZip::CaseSensitivity,QObject*) or by calling setFileName().

Returns unpredictable value if getFileName() returns null string (this is the case when you did not used setFileName() or constructor above).

See Also
getFileName

Definition at line 484 of file quazipfile.cpp.

References QuaZipFilePrivate::caseSensitivity, and p.

485 {
486  return p->caseSensitivity;
487 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
QuaZip::CaseSensitivity caseSensitivity
Case sensitivity mode.
Definition: quazipfile.cpp:47
bool QuaZipFile::getFileInfo ( QuaZipFileInfo info)

This function does the same thing as calling QuaZip::getCurrentFileInfo() on the associated QuaZip object, but you can not call getCurrentFileInfo() if the associated QuaZip is internal (because you do not have access to it), while you still can call this function in that case.

File must be open for reading before calling this function.

Returns
false in the case of an error.

This function doesn't support zip64, but will still work fine on zip64 archives if file sizes are below 4 GB, otherwise the values will be set as if converted using QuaZipFileInfo64::toQuaZipFileInfo().

See Also
getFileInfo(QuaZipFileInfo64*)

Definition at line 413 of file quazipfile.cpp.

References QuaZipFileInfo64::toQuaZipFileInfo().

414 {
415  QuaZipFileInfo64 info64;
416  if (getFileInfo(&info64)) {
417  info64.toQuaZipFileInfo(*info);
418  return true;
419  } else {
420  return false;
421  }
422 }
bool toQuaZipFileInfo(QuaZipFileInfo &info) const
Converts to QuaZipFileInfo.
Information about a file inside archive (with zip64 support).
bool getFileInfo(QuaZipFileInfo *info)
Gets information about current file.
Definition: quazipfile.cpp:413

+ Here is the call graph for this function:

bool QuaZipFile::getFileInfo ( QuaZipFileInfo64 info)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

See Also
getFileInfo(QuaZipFileInfo*)

Definition at line 424 of file quazipfile.cpp.

References QuaZip::getCurrentFileInfo(), QuaZip::getMode(), QuaZip::getZipError(), QuaZip::mdUnzip, p, QuaZipFilePrivate::setZipError(), UNZ_OK, QuaZipFilePrivate::zip, and QuaZipFilePrivate::zipError.

425 {
426  if(p->zip==NULL||p->zip->getMode()!=QuaZip::mdUnzip) return false;
427  p->zip->getCurrentFileInfo(info);
428  p->setZipError(p->zip->getZipError());
429  return p->zipError==UNZ_OK;
430 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
int zipError
The last error.
Definition: quazipfile.cpp:67
#define UNZ_OK
Definition: unzip.h:79
Mode getMode() const
Returns the mode in which ZIP file was opened.
Definition: quazip.cpp:614
int getZipError() const
Returns the error code of the last operation.
Definition: quazip.cpp:624
void setZipError(int zipError) const
Sets the zip error.
Definition: quazipfile.cpp:211
ZIP file is open for reading files inside it.
Definition: quazip.h:96
QuaZip * zip
The QuaZip object to work with.
Definition: quazipfile.cpp:43
bool getCurrentFileInfo(QuaZipFileInfo *info) const
Retrieves information about the current file.
Definition: quazip.cpp:492

+ Here is the call graph for this function:

QString QuaZipFile::getFileName ( ) const

This function returns file name you passed to this object either by using QuaZipFile(const QString&,const QString&,QuaZip::CaseSensitivity,QObject*) or by calling setFileName(). Real name of the file may differ in case if you used case-insensitivity.

Returns null string if there is no file name set yet. This is the case when this QuaZipFile operates on the existing QuaZip object (constructor QuaZipFile(QuaZip*,QObject*) or setZip() was used).

See Also
getActualFileName

Definition at line 479 of file quazipfile.cpp.

References QuaZipFilePrivate::fileName, and p.

480 {
481  return p->fileName;
482 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
QString fileName
The file name.
Definition: quazipfile.cpp:45
QuaZip * QuaZipFile::getZip ( ) const

Returns NULL if there is no associated QuaZip or it is internal (so you will not mess with it).

Definition at line 150 of file quazipfile.cpp.

References QuaZipFilePrivate::internal, p, and QuaZipFilePrivate::zip.

151 {
152  return p->internal ? NULL : p->zip;
153 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
bool internal
Whether zip points to an internal QuaZip instance.
Definition: quazipfile.cpp:65
QuaZip * zip
The QuaZip object to work with.
Definition: quazipfile.cpp:43
int QuaZipFile::getZipError ( ) const

Definition at line 494 of file quazipfile.cpp.

References p, and QuaZipFilePrivate::zipError.

Referenced by JlCompress::compressFile(), and JlCompress::extractFile().

495 {
496  return p->zipError;
497 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
int zipError
The last error.
Definition: quazipfile.cpp:67

+ Here is the caller graph for this function:

QString QuaZipFile::getZipName ( ) const

If this object was created by passing QuaZip pointer to the constructor, this function will return that QuaZip's file name (or null string if that object does not have file name yet).

Otherwise, returns associated ZIP archive file name or null string if there are no name set yet.

See Also
setZipName() getFileName()

Definition at line 145 of file quazipfile.cpp.

References QuaZip::getZipName(), p, and QuaZipFilePrivate::zip.

146 {
147  return p->zip==NULL ? QString() : p->zip->getZipName();
148 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
QString getZipName() const
Returns the ZIP archive file name.
Definition: quazipfile.cpp:145
QuaZip * zip
The QuaZip object to work with.
Definition: quazipfile.cpp:43

+ Here is the call graph for this function:

bool QuaZipFile::isRaw ( ) const

If the file is not open, the returned value is undefined.

See Also
open(OpenMode,int*,int*,bool,const char*)

Definition at line 489 of file quazipfile.cpp.

References p, and QuaZipFilePrivate::raw.

Referenced by close().

490 {
491  return p->raw;
492 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
bool raw
Whether this file is opened in the raw mode.
Definition: quazipfile.cpp:49

+ Here is the caller graph for this function:

bool QuaZipFile::isSequential ( ) const
virtual

Definition at line 337 of file quazipfile.cpp.

338 {
339  return true;
340 }
bool QuaZipFile::open ( OpenMode  mode)
virtual

Returns true on success, false otherwise. Call getZipError() to get error code.

Note
Since ZIP/UNZIP API provides buffered reading only, QuaZipFile does not support unbuffered reading. So do not pass QIODevice::Unbuffered flag in mode, or open will fail.

Definition at line 221 of file quazipfile.cpp.

Referenced by KbFirmware::_fileForBoard(), JlCompress::compressFile(), JlCompress::compressSubDir(), and JlCompress::extractFile().

222 {
223  return open(mode, NULL);
224 }
virtual bool open(OpenMode mode)
Opens a file for reading.
Definition: quazipfile.cpp:221

+ Here is the caller graph for this function:

bool QuaZipFile::open ( OpenMode  mode,
const char *  password 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Argument password specifies a password to decrypt the file. If it is NULL then this function behaves just like open(OpenMode).

Definition at line 298 of file quazipfile.h.

299  {return open(mode, NULL, NULL, false, password);}
virtual bool open(OpenMode mode)
Opens a file for reading.
Definition: quazipfile.cpp:221
bool QuaZipFile::open ( OpenMode  mode,
int *  method,
int *  level,
bool  raw,
const char *  password = NULL 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Argument password specifies a password to decrypt the file.

An integers pointed by method and level will receive codes of the compression method and level used. See unzip.h.

If raw is true then no decompression is performed.

method should not be NULL. level can be NULL if you don't want to know the compression level.

Definition at line 226 of file quazipfile.cpp.

References QuaZipFilePrivate::caseSensitivity, QuaZip::close(), QuaZipFilePrivate::fileName, QuaZip::getMode(), QuaZip::getUnzFile(), QuaZip::getZipError(), QuaZip::hasCurrentFile(), QuaZipFilePrivate::internal, QuaZip::mdUnzip, QuaZip::open(), p, QuaZipFilePrivate::raw, QuaZipFilePrivate::resetZipError(), QuaZip::setCurrentFile(), QuaZipFilePrivate::setZipError(), UNZ_OK, unzOpenCurrentFile3(), QuaZipFilePrivate::zip, and QuaZipFilePrivate::zipError.

227 {
228  p->resetZipError();
229  if(isOpen()) {
230  qWarning("QuaZipFile::open(): already opened");
231  return false;
232  }
233  if(mode&Unbuffered) {
234  qWarning("QuaZipFile::open(): Unbuffered mode is not supported");
235  return false;
236  }
237  if((mode&ReadOnly)&&!(mode&WriteOnly)) {
238  if(p->internal) {
239  if(!p->zip->open(QuaZip::mdUnzip)) {
240  p->setZipError(p->zip->getZipError());
241  return false;
242  }
244  p->setZipError(p->zip->getZipError());
245  p->zip->close();
246  return false;
247  }
248  } else {
249  if(p->zip==NULL) {
250  qWarning("QuaZipFile::open(): zip is NULL");
251  return false;
252  }
253  if(p->zip->getMode()!=QuaZip::mdUnzip) {
254  qWarning("QuaZipFile::open(): file open mode %d incompatible with ZIP open mode %d",
255  (int)mode, (int)p->zip->getMode());
256  return false;
257  }
258  if(!p->zip->hasCurrentFile()) {
259  qWarning("QuaZipFile::open(): zip does not have current file");
260  return false;
261  }
262  }
263  p->setZipError(unzOpenCurrentFile3(p->zip->getUnzFile(), method, level, (int)raw, password));
264  if(p->zipError==UNZ_OK) {
265  setOpenMode(mode);
266  p->raw=raw;
267  return true;
268  } else
269  return false;
270  }
271  qWarning("QuaZipFile::open(): open mode %d not supported by this function", (int)mode);
272  return false;
273 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
int zipError
The last error.
Definition: quazipfile.cpp:67
#define UNZ_OK
Definition: unzip.h:79
Mode getMode() const
Returns the mode in which ZIP file was opened.
Definition: quazip.cpp:614
int ZEXPORT unzOpenCurrentFile3(unzFile file, int *method, int *level, int raw, const char *password)
Definition: unzip.c:1480
int getZipError() const
Returns the error code of the last operation.
Definition: quazip.cpp:624
void setZipError(int zipError) const
Sets the zip error.
Definition: quazipfile.cpp:211
QString fileName
The file name.
Definition: quazipfile.cpp:45
bool internal
Whether zip points to an internal QuaZip instance.
Definition: quazipfile.cpp:65
bool setCurrentFile(const QString &fileName, CaseSensitivity cs=csDefault)
Sets current file by its name.
Definition: quazip.cpp:408
ZIP file is open for reading files inside it.
Definition: quazip.h:96
void close()
Closes ZIP file.
Definition: quazip.cpp:324
QuaZip::CaseSensitivity caseSensitivity
Case sensitivity mode.
Definition: quazipfile.cpp:47
unzFile getUnzFile()
Returns unzFile handle.
Definition: quazip.cpp:639
bool open(Mode mode, zlib_filefunc_def *ioApi=NULL)
Opens ZIP file.
Definition: quazip.cpp:215
bool hasCurrentFile() const
Returns true if the current file has been set.
Definition: quazip.cpp:634
QuaZip * zip
The QuaZip object to work with.
Definition: quazipfile.cpp:43
bool raw
Whether this file is opened in the raw mode.
Definition: quazipfile.cpp:49
void resetZipError() const
Resets zipError.
Definition: quazipfile.cpp:69

+ Here is the call graph for this function:

bool QuaZipFile::open ( OpenMode  mode,
const QuaZipNewInfo info,
const char *  password = NULL,
quint32  crc = 0,
int  method = Z_DEFLATED,
int  level = Z_DEFAULT_COMPRESSION,
bool  raw = false,
int  windowBits = -MAX_WBITS,
int  memLevel = MAX_MEM_LEVEL,
int  strategy = Z_DEFAULT_STRATEGY 
)

info argument specifies information about file. It should at least specify a correct file name. Also, it is a good idea to specify correct timestamp (by default, current time will be used). See QuaZipNewInfo.

The password argument specifies the password for crypting. Pass NULL if you don't need any crypting. The crc argument was supposed to be used for crypting too, but then it turned out that it's false information, so you need to set it to 0 unless you want to use the raw mode (see below).

Arguments method and level specify compression method and level. The only method supported is Z_DEFLATED, but you may also specify 0 for no compression. If all of the files in the archive use both method 0 and either level 0 is explicitly specified or data descriptor writing is disabled with QuaZip::setDataDescriptorWritingEnabled(), then the resulting archive is supposed to be compatible with the 1.0 ZIP format version, should you need that. Except for this, level has no other effects with method 0.

If raw is true, no compression is performed. In this case, crc and uncompressedSize field of the info are required.

Arguments windowBits, memLevel, strategy provide zlib algorithms tuning. See deflateInit2() in zlib.

Definition at line 275 of file quazipfile.cpp.

References QuaZipNewInfo::comment, QuaZipFilePrivate::crc, QuaZipNewInfo::dateTime, zip_fileinfo::dosDate, zip_fileinfo::external_fa, QuaZipNewInfo::externalAttr, QuaZipNewInfo::extraGlobal, QuaZipNewInfo::extraLocal, QuaZip::getCommentCodec(), QuaZip::getFileNameCodec(), QuaZip::getMode(), QuaZip::getZipFile(), QuaZipFilePrivate::internal, zip_fileinfo::internal_fa, QuaZipNewInfo::internalAttr, QuaZip::isDataDescriptorWritingEnabled(), QuaZip::isZip64Enabled(), QuaZip::mdAdd, QuaZip::mdAppend, QuaZip::mdCreate, QuaZipNewInfo::name, p, QuaZipFilePrivate::raw, QuaZipFilePrivate::resetZipError(), QuaZipFilePrivate::setZipError(), tm_zip_s::tm_hour, tm_zip_s::tm_mday, tm_zip_s::tm_min, tm_zip_s::tm_mon, tm_zip_s::tm_sec, tm_zip_s::tm_year, zip_fileinfo::tmz_date, QuaZipFilePrivate::uncompressedSize, QuaZipNewInfo::uncompressedSize, UNZ_OK, QuaZipFilePrivate::writePos, QuaZipFilePrivate::zip, ZIP_WRITE_DATA_DESCRIPTOR, zipClearFlags(), QuaZipFilePrivate::zipError, zipOpenNewFileInZip3_64(), and zipSetFlags().

279 {
280  zip_fileinfo info_z;
281  p->resetZipError();
282  if(isOpen()) {
283  qWarning("QuaZipFile::open(): already opened");
284  return false;
285  }
286  if((mode&WriteOnly)&&!(mode&ReadOnly)) {
287  if(p->internal) {
288  qWarning("QuaZipFile::open(): write mode is incompatible with internal QuaZip approach");
289  return false;
290  }
291  if(p->zip==NULL) {
292  qWarning("QuaZipFile::open(): zip is NULL");
293  return false;
294  }
296  qWarning("QuaZipFile::open(): file open mode %d incompatible with ZIP open mode %d",
297  (int)mode, (int)p->zip->getMode());
298  return false;
299  }
300  info_z.tmz_date.tm_year=info.dateTime.date().year();
301  info_z.tmz_date.tm_mon=info.dateTime.date().month() - 1;
302  info_z.tmz_date.tm_mday=info.dateTime.date().day();
303  info_z.tmz_date.tm_hour=info.dateTime.time().hour();
304  info_z.tmz_date.tm_min=info.dateTime.time().minute();
305  info_z.tmz_date.tm_sec=info.dateTime.time().second();
306  info_z.dosDate = 0;
307  info_z.internal_fa=(uLong)info.internalAttr;
308  info_z.external_fa=(uLong)info.externalAttr;
311  else
314  p->zip->getFileNameCodec()->fromUnicode(info.name).constData(), &info_z,
315  info.extraLocal.constData(), info.extraLocal.length(),
316  info.extraGlobal.constData(), info.extraGlobal.length(),
317  p->zip->getCommentCodec()->fromUnicode(info.comment).constData(),
318  method, level, (int)raw,
319  windowBits, memLevel, strategy,
320  password, (uLong)crc, p->zip->isZip64Enabled()));
321  if(p->zipError==UNZ_OK) {
322  p->writePos=0;
323  setOpenMode(mode);
324  p->raw=raw;
325  if(raw) {
326  p->crc=crc;
328  }
329  return true;
330  } else
331  return false;
332  }
333  qWarning("QuaZipFile::open(): open mode %d not supported by this function", (int)mode);
334  return false;
335 }
quint32 crc
CRC to write along with a raw file.
Definition: quazipfile.cpp:59
QuaZipFilePrivate * p
Definition: quazipfile.h:78
tm_zip tmz_date
Definition: zip.h:112
#define ZIP_WRITE_DATA_DESCRIPTOR
Definition: zip.h:85
int zipError
The last error.
Definition: quazipfile.cpp:67
uLong external_fa
Definition: zip.h:117
#define UNZ_OK
Definition: unzip.h:79
QTextCodec * getCommentCodec() const
Returns the codec used to encode/decode comments inside archive.
Definition: quazip.cpp:597
quint16 internalAttr
File internal attributes.
Definition: quazipnewinfo.h:64
QByteArray extraLocal
File local extra field.
Definition: quazipnewinfo.h:77
ulong uncompressedSize
Uncompressed file size.
Definition: quazipnewinfo.h:84
QString comment
File comment.
Definition: quazipnewinfo.h:75
uInt tm_min
Definition: zip.h:103
ZIP file was opened for adding files in the archive.
Definition: quazip.h:106
Mode getMode() const
Returns the mode in which ZIP file was opened.
Definition: quazip.cpp:614
ZIP file was created with open() call.
Definition: quazip.h:97
uInt tm_hour
Definition: zip.h:104
qint64 writePos
Write position to keep track of.
Definition: quazipfile.cpp:55
void setZipError(int zipError) const
Sets the zip error.
Definition: quazipfile.cpp:211
uInt tm_sec
Definition: zip.h:102
int ZEXPORT zipSetFlags(zipFile file, unsigned flags)
Definition: zip.c:2077
zipFile getZipFile()
Returns zipFile handle.
Definition: quazip.cpp:644
bool internal
Whether zip points to an internal QuaZip instance.
Definition: quazipfile.cpp:65
bool isZip64Enabled() const
Returns whether the zip64 mode is enabled.
Definition: quazip.cpp:775
uLong dosDate
Definition: zip.h:113
QDateTime dateTime
File timestamp.
Definition: quazipnewinfo.h:62
QByteArray extraGlobal
File global extra field.
Definition: quazipnewinfo.h:79
QTextCodec * getFileNameCodec() const
Returns the codec used to encode/decode comments inside archive.
Definition: quazip.cpp:582
uInt tm_mday
Definition: zip.h:105
uInt tm_mon
Definition: zip.h:106
quint32 externalAttr
File external attributes.
Definition: quazipnewinfo.h:71
QString name
File name.
Definition: quazipnewinfo.h:55
int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, uLong crcForCrypting, int zip64)
Definition: zip.c:1336
bool isDataDescriptorWritingEnabled() const
Returns the data descriptor default writing mode.
Definition: quazip.cpp:654
ZIP file was opened in append mode.
Definition: quazip.h:98
uLong internal_fa
Definition: zip.h:116
QuaZip * zip
The QuaZip object to work with.
Definition: quazipfile.cpp:43
bool raw
Whether this file is opened in the raw mode.
Definition: quazipfile.cpp:49
quint64 uncompressedSize
Uncompressed size to write along with a raw file.
Definition: quazipfile.cpp:57
int ZEXPORT zipClearFlags(zipFile file, unsigned flags)
Definition: zip.c:2091
void resetZipError() const
Resets zipError.
Definition: quazipfile.cpp:69
uInt tm_year
Definition: zip.h:107

+ Here is the call graph for this function:

QuaZipFile& QuaZipFile::operator= ( const QuaZipFile that)
private
qint64 QuaZipFile::pos ( ) const
virtual

Implementation of the QIODevice::pos(). When reading, this function is a wrapper to the ZIP/UNZIP unztell(), therefore it is unable to keep track of the ungetChar() calls (which is non-virtual and therefore is dangerous to reimplement). So if you are using ungetChar() feature of the QIODevice, this function reports incorrect value until you get back characters which you ungot.

When writing, pos() returns number of bytes already written (uncompressed unless you use raw mode).

Note
Although QuaZipFile is a sequential device and therefore pos() should always return zero, it does not, because it would be misguiding. Keep this in mind.

This function returns -1 if the file or archive is not open.

Error code returned by getZipError() is not affected by this function call.

Definition at line 342 of file quazipfile.cpp.

References QuaZip::getUnzFile(), p, unztell(), QuaZipFilePrivate::writePos, and QuaZipFilePrivate::zip.

Referenced by bytesAvailable().

343 {
344  if(p->zip==NULL) {
345  qWarning("QuaZipFile::pos(): call setZipName() or setZip() first");
346  return -1;
347  }
348  if(!isOpen()) {
349  qWarning("QuaZipFile::pos(): file is not open");
350  return -1;
351  }
352  if(openMode()&ReadOnly)
353  // QIODevice::pos() is broken for sequential devices,
354  // but thankfully bytesAvailable() returns the number of
355  // bytes buffered, so we know how far ahead we are.
356  return unztell(p->zip->getUnzFile()) - QIODevice::bytesAvailable();
357  else
358  return p->writePos;
359 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
qint64 writePos
Write position to keep track of.
Definition: quazipfile.cpp:55
unzFile getUnzFile()
Returns unzFile handle.
Definition: quazip.cpp:639
z_off_t ZEXPORT unztell(unzFile file)
Definition: unzip.c:1897
QuaZip * zip
The QuaZip object to work with.
Definition: quazipfile.cpp:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

qint64 QuaZipFile::readData ( char *  data,
qint64  maxSize 
)
protected

Definition at line 457 of file quazipfile.cpp.

References QuaZip::getUnzFile(), p, QuaZipFilePrivate::setZipError(), UNZ_OK, unzReadCurrentFile(), and QuaZipFilePrivate::zip.

458 {
459  p->setZipError(UNZ_OK);
460  qint64 bytesRead=unzReadCurrentFile(p->zip->getUnzFile(), data, (unsigned)maxSize);
461  if (bytesRead < 0) {
462  p->setZipError((int) bytesRead);
463  return -1;
464  }
465  return bytesRead;
466 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
#define UNZ_OK
Definition: unzip.h:79
void setZipError(int zipError) const
Sets the zip error.
Definition: quazipfile.cpp:211
int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len)
Addition for GDAL : END.
Definition: unzip.c:1692
unzFile getUnzFile()
Returns unzFile handle.
Definition: quazip.cpp:639
QuaZip * zip
The QuaZip object to work with.
Definition: quazipfile.cpp:43

+ Here is the call graph for this function:

void QuaZipFile::setFileName ( const QString &  fileName,
QuaZip::CaseSensitivity  cs = QuaZip::csDefault 
)

Will do nothing if at least one of the following conditions is met:

  • ZIP name has not been set yet (getZipName() returns null string).
  • This QuaZipFile is associated with external QuaZip. In this case you should call that QuaZip's setCurrentFile() function instead!
  • File is already open so setting the name is meaningless.
See Also
QuaZip::setCurrentFile

Definition at line 191 of file quazipfile.cpp.

References QuaZipFilePrivate::caseSensitivity, QuaZipFilePrivate::fileName, QuaZipFilePrivate::internal, p, and QuaZipFilePrivate::zip.

192 {
193  if(p->zip==NULL) {
194  qWarning("QuaZipFile::setFileName(): call setZipName() first");
195  return;
196  }
197  if(!p->internal) {
198  qWarning("QuaZipFile::setFileName(): should not be used when not using internal QuaZip");
199  return;
200  }
201  if(isOpen()) {
202  qWarning("QuaZipFile::setFileName(): can not set file name for already opened file");
203  return;
204  }
205  p->fileName=fileName;
206  if (p->fileName.startsWith('/'))
207  p->fileName = p->fileName.mid(1);
208  p->caseSensitivity=cs;
209 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
QString fileName
The file name.
Definition: quazipfile.cpp:45
bool internal
Whether zip points to an internal QuaZip instance.
Definition: quazipfile.cpp:65
QuaZip::CaseSensitivity caseSensitivity
Case sensitivity mode.
Definition: quazipfile.cpp:47
QuaZip * zip
The QuaZip object to work with.
Definition: quazipfile.cpp:43
void QuaZipFile::setZip ( QuaZip zip)

This function destroys internal QuaZip object, if any, and makes this QuaZipFile to use current file in the zip object for any further operations. See QuaZipFile(QuaZip*,QObject*) for the possible pitfalls.

Will do nothing if the file is currently open. You must close() it first.

Definition at line 178 of file quazipfile.cpp.

References QuaZipFilePrivate::fileName, QuaZipFilePrivate::internal, p, and QuaZipFilePrivate::zip.

179 {
180  if(isOpen()) {
181  qWarning("QuaZipFile::setZip(): file is already open - can not set ZIP");
182  return;
183  }
184  if(p->zip!=NULL && p->internal)
185  delete p->zip;
186  p->zip=zip;
187  p->fileName=QString();
188  p->internal=false;
189 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
QString fileName
The file name.
Definition: quazipfile.cpp:45
bool internal
Whether zip points to an internal QuaZip instance.
Definition: quazipfile.cpp:65
QuaZip * zip
The QuaZip object to work with.
Definition: quazipfile.cpp:43
void QuaZipFile::setZipName ( const QString &  zipName)

Automatically creates internal QuaZip object and destroys previously created internal QuaZip object, if any.

Will do nothing if this file is already open. You must close() it first.

Definition at line 166 of file quazipfile.cpp.

References QuaZipFilePrivate::internal, p, and QuaZipFilePrivate::zip.

167 {
168  if(isOpen()) {
169  qWarning("QuaZipFile::setZipName(): file is already open - can not set ZIP name");
170  return;
171  }
172  if(p->zip!=NULL && p->internal)
173  delete p->zip;
174  p->zip=new QuaZip(zipName);
175  p->internal=true;
176 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
bool internal
Whether zip points to an internal QuaZip instance.
Definition: quazipfile.cpp:65
ZIP archive.
Definition: quazip.h:84
QuaZip * zip
The QuaZip object to work with.
Definition: quazipfile.cpp:43
qint64 QuaZipFile::size ( ) const
virtual

This function returns csize() if the file is open for reading in raw mode, usize() if it is open for reading in normal mode and pos() if it is open for writing.

Returns -1 on error, call getZipError() to get error code.

Note
This function returns file size despite that QuaZipFile is considered to be sequential device, for which size() should return bytesAvailable() instead. But its name would be very misguiding otherwise, so just keep in mind this inconsistence.

Definition at line 379 of file quazipfile.cpp.

References csize(), p, QuaZipFilePrivate::raw, usize(), and QuaZipFilePrivate::writePos.

Referenced by bytesAvailable().

380 {
381  if(!isOpen()) {
382  qWarning("QuaZipFile::atEnd(): file is not open");
383  return -1;
384  }
385  if(openMode()&ReadOnly)
386  return p->raw?csize():usize();
387  else
388  return p->writePos;
389 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
qint64 csize() const
Returns compressed file size.
Definition: quazipfile.cpp:391
qint64 writePos
Write position to keep track of.
Definition: quazipfile.cpp:55
qint64 usize() const
Returns uncompressed file size.
Definition: quazipfile.cpp:402
bool raw
Whether this file is opened in the raw mode.
Definition: quazipfile.cpp:49

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

qint64 QuaZipFile::usize ( ) const

Equivalent to calling getFileInfo() and then getting uncompressedSize field, but more convenient and faster. See getFileInfo() for a warning.

File must be open for reading before calling this function.

Returns -1 on error, call getZipError() to get error code.

Definition at line 402 of file quazipfile.cpp.

References QuaZip::getMode(), QuaZip::getUnzFile(), QuaZip::mdUnzip, p, QuaZipFilePrivate::setZipError(), unz_file_info64_s::uncompressed_size, UNZ_OK, unzGetCurrentFileInfo64(), QuaZipFilePrivate::zip, and QuaZipFilePrivate::zipError.

Referenced by size().

403 {
404  unz_file_info64 info_z;
405  p->setZipError(UNZ_OK);
406  if(p->zip==NULL||p->zip->getMode()!=QuaZip::mdUnzip) return -1;
407  p->setZipError(unzGetCurrentFileInfo64(p->zip->getUnzFile(), &info_z, NULL, 0, NULL, 0, NULL, 0));
408  if(p->zipError!=UNZ_OK)
409  return -1;
410  return info_z.uncompressed_size;
411 }
QuaZipFilePrivate * p
Definition: quazipfile.h:78
int zipError
The last error.
Definition: quazipfile.cpp:67
#define UNZ_OK
Definition: unzip.h:79
Mode getMode() const
Returns the mode in which ZIP file was opened.
Definition: quazip.cpp:614
void setZipError(int zipError) const
Sets the zip error.
Definition: quazipfile.cpp:211
ZPOS64_T uncompressed_size
Definition: unzip.h:128
ZIP file is open for reading files inside it.
Definition: quazip.h:96
int ZEXPORT unzGetCurrentFileInfo64(unzFile file, unz_file_info64 *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
Definition: unzip.c:1134
unzFile getUnzFile()
Returns unzFile handle.
Definition: quazip.cpp:639
QuaZip * zip
The QuaZip object to work with.
Definition: quazipfile.cpp:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

qint64 QuaZipFile::writeData ( const char *  data,
qint64  maxSize 
)
protected

Definition at line 468 of file quazipfile.cpp.

References QuaZip::getZipFile(), p, QuaZipFilePrivate::setZipError(), QuaZipFilePrivate::writePos, QuaZipFilePrivate::zip, ZIP_OK, QuaZipFilePrivate::zipError, and zipWriteInFileInZip().

469 {
470  p->setZipError(ZIP_OK);
471  p->setZipError(zipWriteInFileInZip(p->zip->getZipFile(), data, (uint)maxSize));
472  if(p->zipError!=ZIP_OK) return -1;
473  else {
474  p->writePos+=maxSize;
475  return maxSize;
476  }
477 }
#define ZIP_OK
Definition: zip.h:78
QuaZipFilePrivate * p
Definition: quazipfile.h:78
int zipError
The last error.
Definition: quazipfile.cpp:67
qint64 writePos
Write position to keep track of.
Definition: quazipfile.cpp:55
void setZipError(int zipError) const
Sets the zip error.
Definition: quazipfile.cpp:211
int ZEXPORT zipWriteInFileInZip(zipFile file, const void *buf, unsigned int len)
Definition: zip.c:1442
zipFile getZipFile()
Returns zipFile handle.
Definition: quazip.cpp:644
QuaZip * zip
The QuaZip object to work with.
Definition: quazipfile.cpp:43

+ Here is the call graph for this function:

Friends And Related Function Documentation

friend class QuaZipFilePrivate
friend

Definition at line 75 of file quazipfile.h.

Field Documentation


The documentation for this class was generated from the following files: