Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QZipReader Class Reference

\variable QZipReader::FileInfo::filePath The full filepath inside the archive. More...

#include <qzipreader_p.h>

Collaboration diagram for QZipReader:

Classes

class  FileInfo

Public Types

enum  Status {
  NoError , FileReadError , FileOpenError , FilePermissionsError ,
  FileError
}
 The following status values are possible: More...

Public Member Functions

 QZipReader (const QString &fileName, QIODevice::OpenMode mode=QIODevice::ReadOnly)
 Create a new zip archive that operates on the fileName.
 QZipReader (QIODevice *device)
 Create a new zip archive that operates on the archive found in device.
 ~QZipReader ()
 Destructor.
QIODevicedevice () const
 Returns device used for reading zip archive.
bool isReadable () const
 Returns true if the user can read the file; otherwise returns false.
bool exists () const
 Returns true if the file exists; otherwise returns false.
QList< FileInfofileInfoList () const
 Returns the list of files the archive contains.
int count () const
 Return the number of items in the zip archive.
FileInfo entryInfoAt (int index) const
 Returns a FileInfo of an entry in the zipfile.
QByteArray fileData (const QString &fileName) const
 Fetch the file contents from the zip archive and return the uncompressed bytes.
bool extractAll (const QString &destinationDir) const
 Extracts the full contents of the zip file into destinationDir on the local filesystem.
Status status () const
 Returns a status code indicating the first error that was met by QZipReader, or QZipReader::NoError if no error occurred.
void close ()
 Close the zip file.

Detailed Description

\variable QZipReader::FileInfo::filePath The full filepath inside the archive.

\variable QZipReader::FileInfo::isDir A boolean type indicating if the entry is a directory.

\variable QZipReader::FileInfo::isFile A boolean type, if it is one this entry is a file.

\variable QZipReader::FileInfo::isSymLink A boolean type, if it is one this entry is symbolic link.

\variable QZipReader::FileInfo::permissions A list of flags for the permissions of this entry.

\variable QZipReader::FileInfo::crc The calculated checksum as a crc type.

\variable QZipReader::FileInfo::size The total size of the unpacked content.

Since
4.5

the QZipReader class provides a way to inspect the contents of a zip archive and extract individual files from it.

QZipReader can be used to read a zip archive either from a file or from any device. An in-memory QBuffer for instance. The reader can be used to read which files are in the archive using fileInfoList() and entryInfoAt() but also to extract individual files using fileData() or even to extract all files in the archive using extractAll()

Definition at line 29 of file qzipreader_p.h.

Member Enumeration Documentation

◆ Status

The following status values are possible:

\value NoError No error occurred. \value FileReadError An error occurred when reading from the file. \value FileOpenError The file could not be opened. \value FilePermissionsError The file could not be accessed. \value FileError Another file error occurred.

Enumerator
NoError 
FileReadError 
FileOpenError 
FilePermissionsError 
FileError 

Definition at line 67 of file qzipreader_p.h.

Constructor & Destructor Documentation

◆ QZipReader() [1/2]

QZipReader::QZipReader ( const QString & archive,
QIODevice::OpenMode mode = QIODevice::ReadOnly )
explicit

Create a new zip archive that operates on the fileName.

The file will be opened with the mode.

Definition at line 784 of file qzip.cpp.

◆ QZipReader() [2/2]

QZipReader::QZipReader ( QIODevice * device)
explicit

Create a new zip archive that operates on the archive found in device.

You have to open the device previous to calling the constructor and only a device that is readable will be scanned for zip filecontent.

Definition at line 813 of file qzip.cpp.

◆ ~QZipReader()

QZipReader::~QZipReader ( )

Destructor.

Definition at line 822 of file qzip.cpp.

Member Function Documentation

◆ close()

void QZipReader::close ( )

Close the zip file.

Definition at line 1078 of file qzip.cpp.

◆ count()

int QZipReader::count ( ) const

Return the number of items in the zip archive.

Definition at line 873 of file qzip.cpp.

◆ device()

QIODevice * QZipReader::device ( ) const

Returns device used for reading zip archive.

Definition at line 831 of file qzip.cpp.

◆ entryInfoAt()

QZipReader::FileInfo QZipReader::entryInfoAt ( int index) const

Returns a FileInfo of an entry in the zipfile.

The index is the index into the directory listing of the zipfile. Returns an invalid FileInfo if index is out of boundaries.

See also
fileInfoList()

Definition at line 886 of file qzip.cpp.

◆ exists()

bool QZipReader::exists ( ) const

Returns true if the file exists; otherwise returns false.

Definition at line 847 of file qzip.cpp.

◆ extractAll()

bool QZipReader::extractAll ( const QString & destinationDir) const

Extracts the full contents of the zip file into destinationDir on the local filesystem.

In case writing or linking a file fails, the extraction will be aborted.

Definition at line 982 of file qzip.cpp.

◆ fileData()

QByteArray QZipReader::fileData ( const QString & fileName) const

Fetch the file contents from the zip archive and return the uncompressed bytes.

Definition at line 897 of file qzip.cpp.

◆ fileInfoList()

QList< QZipReader::FileInfo > QZipReader::fileInfoList ( ) const

Returns the list of files the archive contains.

Definition at line 858 of file qzip.cpp.

◆ isReadable()

bool QZipReader::isReadable ( ) const

Returns true if the user can read the file; otherwise returns false.

Definition at line 839 of file qzip.cpp.

◆ status()

QZipReader::Status QZipReader::status ( ) const

Returns a status code indicating the first error that was met by QZipReader, or QZipReader::NoError if no error occurred.

Definition at line 1070 of file qzip.cpp.


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