Qt 4.8
|
the QZipReader class provides a way to inspect the contents of a zip archive and extract individual files from it. More...
#include <qzipreader_p.h>
Classes | |
class | FileInfo |
Represents one entry in the zip table of contents. More... | |
Public Types | |
enum | Status { NoError, FileReadError, FileOpenError, FilePermissionsError, FileError } |
The following status values are possible: More... | |
Public Functions | |
void | close () |
Close the zip file. More... | |
int | count () const |
Return the number of items in the zip archive. More... | |
QIODevice * | device () const |
Returns device used for reading zip archive. More... | |
FileInfo | entryInfoAt (int index) const |
Returns a FileInfo of an entry in the zipfile. More... | |
bool | exists () const |
Returns true if the file exists; otherwise returns false. More... | |
bool | extractAll (const QString &destinationDir) const |
Extracts the full contents of the zip file into destinationDir on the local filesystem. More... | |
QByteArray | fileData (const QString &fileName) const |
Fetch the file contents from the zip archive and return the uncompressed bytes. More... | |
QList< FileInfo > | fileInfoList () const |
Returns the list of files the archive contains. More... | |
bool | isReadable () const |
Returns true if the user can read the file; otherwise returns false. More... | |
QZipReader (const QString &fileName, QIODevice::OpenMode mode=QIODevice::ReadOnly) | |
Create a new zip archive that operates on the fileName. More... | |
QZipReader (QIODevice *device) | |
Create a new zip archive that operates on the archive found in device. More... | |
Status | status () const |
Returns a status code indicating the first error that was met by QZipReader, or QZipReader::NoError if no error occurred. More... | |
~QZipReader () | |
Desctructor. More... | |
Properties | |
QZipReaderPrivate * | d |
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 66 of file qzipreader_p.h.
enum QZipReader::Status |
The following status values are possible:
Enumerator | |
---|---|
NoError | |
FileReadError | |
FileOpenError | |
FilePermissionsError | |
FileError |
Definition at line 104 of file qzipreader_p.h.
QZipReader::QZipReader | ( | const QString & | archive, |
QIODevice::OpenMode | mode = QIODevice::ReadOnly |
||
) |
Create a new zip archive that operates on the fileName.
The file will be opened with the mode.
Definition at line 758 of file qzip.cpp.
|
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 786 of file qzip.cpp.
void QZipReader::close | ( | ) |
Close the zip file.
Definition at line 1021 of file qzip.cpp.
Referenced by ~QZipReader().
int QZipReader::count | ( | ) | const |
Return the number of items in the zip archive.
Definition at line 847 of file qzip.cpp.
QIODevice * QZipReader::device | ( | ) | const |
Returns device used for reading zip archive.
Definition at line 804 of file qzip.cpp.
Referenced by QZipWriterPrivate::addEntry(), QZipReaderPrivate::scanFiles(), and QZipPrivate::~QZipPrivate().
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.
Definition at line 860 of file qzip.cpp.
bool QZipReader::exists | ( | ) | const |
Returns true if the file exists; otherwise returns false.
Definition at line 820 of file qzip.cpp.
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 944 of file qzip.cpp.
QByteArray QZipReader::fileData | ( | const QString & | fileName | ) | const |
Fetch the file contents from the zip archive and return the uncompressed bytes.
Definition at line 872 of file qzip.cpp.
Referenced by extractAll().
QList< QZipReader::FileInfo > QZipReader::fileInfoList | ( | ) | const |
Returns the list of files the archive contains.
Definition at line 831 of file qzip.cpp.
Referenced by extractAll().
bool QZipReader::isReadable | ( | ) | const |
Returns true if the user can read the file; otherwise returns false.
Definition at line 812 of file qzip.cpp.
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 1013 of file qzip.cpp.
Referenced by QZipWriterPrivate::addEntry(), QZipReader(), QZipWriter::QZipWriter(), and QZipReaderPrivate::scanFiles().
|
private |
Definition at line 117 of file qzipreader_p.h.
Referenced by close(), count(), device(), entryInfoAt(), exists(), fileData(), fileInfoList(), isReadable(), QZipWriter::QZipWriter(), status(), and ~QZipReader().