Qt 4.8
|
the QZipWriter class provides a way to create a new zip archive. More...
#include <qzipwriter_p.h>
Public Types | |
enum | CompressionPolicy { AlwaysCompress, NeverCompress, AutoCompress } |
enum | Status { NoError, FileWriteError, FileOpenError, FilePermissionsError, FileError } |
The following status values are possible: More... | |
Public Functions | |
void | addDirectory (const QString &dirName) |
Create a new directory in the archive with the specified dirName and the permissions;. More... | |
void | addFile (const QString &fileName, const QByteArray &data) |
Add a file to the archive with data as the file contents. More... | |
void | addFile (const QString &fileName, QIODevice *device) |
Add a file to the archive with device as the source of the contents. More... | |
void | addSymLink (const QString &fileName, const QString &destination) |
Create a new symbolic link in the archive with the specified dirName and the permissions; A symbolic link contains the destination (relative) path and name. More... | |
void | close () |
Closes the zip file. More... | |
CompressionPolicy | compressionPolicy () const |
Returns the currently set compression policy. More... | |
QFile::Permissions | creationPermissions () const |
Returns the currently set creation permissions. More... | |
QIODevice * | device () const |
Returns device used for writing zip archive. More... | |
bool | exists () const |
Returns true if the file exists; otherwise returns false. More... | |
bool | isWritable () const |
Returns true if the user can write to the archive; otherwise returns false. More... | |
QZipWriter (const QString &fileName, QIODevice::OpenMode mode=(QIODevice::WriteOnly|QIODevice::Truncate)) | |
Create a new zip archive that operates on the archive filename. More... | |
QZipWriter (QIODevice *device) | |
Create a new zip archive that operates on the archive found in device. More... | |
void | setCompressionPolicy (CompressionPolicy policy) |
Sets the policy for compressing newly added files to the new policy. More... | |
void | setCreationPermissions (QFile::Permissions permissions) |
Sets the permissions that will be used for newly added files. More... | |
Status | status () const |
Returns a status code indicating the first error that was met by QZipWriter, or QZipWriter::NoError if no error occurred. More... | |
~QZipWriter () | |
Properties | |
QZipWriterPrivate * | d |
the QZipWriter class provides a way to create a new zip archive.
QZipWriter can be used to create a zip archive containing any number of files and directories. The files in the archive will be compressed in a way that is compatible with common zip reader applications.
Definition at line 64 of file qzipwriter_p.h.
Enumerator | |
---|---|
AlwaysCompress | |
NeverCompress | |
AutoCompress |
Definition at line 87 of file qzipwriter_p.h.
enum QZipWriter::Status |
The following status values are possible:
Enumerator | |
---|---|
NoError | |
FileWriteError | |
FileOpenError | |
FilePermissionsError | |
FileError |
Definition at line 77 of file qzipwriter_p.h.
QZipWriter::QZipWriter | ( | const QString & | fileName, |
QIODevice::OpenMode | mode = (QIODevice::WriteOnly | QIODevice::Truncate) |
||
) |
Create a new zip archive that operates on the archive filename.
The file will be opened with the mode.
Definition at line 1049 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 1077 of file qzip.cpp.
void QZipWriter::addDirectory | ( | const QString & | dirName | ) |
Create a new directory in the archive with the specified dirName and the permissions;.
Definition at line 1240 of file qzip.cpp.
void QZipWriter::addFile | ( | const QString & | fileName, |
const QByteArray & | data | ||
) |
Add a file to the archive with data as the file contents.
The file will be stored in the archive using the fileName which includes the full path in the archive.
The new file will get the file permissions based on the current creationPermissions and it will be compressed using the zip compression based on the current compression policy.
Definition at line 1207 of file qzip.cpp.
Add a file to the archive with device as the source of the contents.
The contents returned from QIODevice::readAll() will be used as the filedata. The file will be stored in the archive using the fileName which includes the full path in the archive.
Definition at line 1219 of file qzip.cpp.
Create a new symbolic link in the archive with the specified dirName and the permissions; A symbolic link contains the destination (relative) path and name.
Definition at line 1254 of file qzip.cpp.
void QZipWriter::close | ( | ) |
Closes the zip file.
Definition at line 1262 of file qzip.cpp.
Referenced by ~QZipWriter().
QZipWriter::CompressionPolicy QZipWriter::compressionPolicy | ( | ) | const |
Returns the currently set compression policy.
Definition at line 1166 of file qzip.cpp.
QFile::Permissions QZipWriter::creationPermissions | ( | ) | const |
Returns the currently set creation permissions.
Definition at line 1190 of file qzip.cpp.
QIODevice * QZipWriter::device | ( | ) | const |
bool QZipWriter::exists | ( | ) | const |
Returns true if the file exists; otherwise returns false.
Definition at line 1108 of file qzip.cpp.
bool QZipWriter::isWritable | ( | ) | const |
Returns true if the user can write to the archive; otherwise returns false.
Definition at line 1100 of file qzip.cpp.
void QZipWriter::setCompressionPolicy | ( | CompressionPolicy | policy | ) |
Sets the policy for compressing newly added files to the new policy.
Definition at line 1156 of file qzip.cpp.
void QZipWriter::setCreationPermissions | ( | QFile::Permissions | permissions | ) |
Sets the permissions that will be used for newly added files.
Definition at line 1179 of file qzip.cpp.
QZipWriter::Status QZipWriter::status | ( | ) | const |
Returns a status code indicating the first error that was met by QZipWriter, or QZipWriter::NoError if no error occurred.
Definition at line 1135 of file qzip.cpp.
|
private |
Definition at line 109 of file qzipwriter_p.h.
Referenced by addDirectory(), addFile(), addSymLink(), close(), compressionPolicy(), creationPermissions(), device(), exists(), isWritable(), setCompressionPolicy(), setCreationPermissions(), status(), and ~QZipWriter().