![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
the QZipWriter class provides a way to create a new zip archive. More...
#include <qzipwriter_p.h>
Public Types | |
enum | Status { NoError , FileWriteError , FileOpenError , FilePermissionsError , FileError } |
The following status values are possible: More... | |
enum | CompressionPolicy { AlwaysCompress , NeverCompress , AutoCompress } |
\value AlwaysCompress A file that is added is compressed. More... |
Public Member Functions | |
QZipWriter (const QString &fileName, QIODevice::OpenMode mode=(QIODevice::WriteOnly|QIODevice::Truncate)) | |
Create a new zip archive that operates on the archive filename. | |
QZipWriter (QIODevice *device) | |
Create a new zip archive that operates on the archive found in device. | |
~QZipWriter () | |
QIODevice * | device () const |
Returns device used for writing zip archive. | |
bool | isWritable () const |
Returns true if the user can write to the archive; otherwise returns false . | |
bool | exists () const |
Returns true if the file exists; otherwise returns false . | |
Status | status () const |
Returns a status code indicating the first error that was met by QZipWriter, or QZipWriter::NoError if no error occurred. | |
void | setCompressionPolicy (CompressionPolicy policy) |
Sets the policy for compressing newly added files to the new policy. | |
CompressionPolicy | compressionPolicy () const |
Returns the currently set compression policy. | |
void | setCreationPermissions (QFile::Permissions permissions) |
Sets the permissions that will be used for newly added files. | |
QFile::Permissions | creationPermissions () const |
Returns the currently set creation permissions. | |
void | addFile (const QString &fileName, const QByteArray &data) |
Add a file to the archive with data as the file contents. | |
void | addFile (const QString &fileName, QIODevice *device) |
Add a file to the archive with device as the source of the contents. | |
void | addDirectory (const QString &dirName) |
Create a new directory in the archive with the specified dirName and the permissions;. | |
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. | |
void | close () |
Closes the zip file. |
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 28 of file qzipwriter_p.h.
\value AlwaysCompress A file that is added is compressed.
\value NeverCompress A file that is added will be stored without changes. \value AutoCompress A file that is added will be compressed only if that will give a smaller file.
Enumerator | |
---|---|
AlwaysCompress | |
NeverCompress | |
AutoCompress |
Definition at line 51 of file qzipwriter_p.h.
enum QZipWriter::Status |
The following status values are possible:
\value NoError No error occurred. \value FileWriteError An error occurred when writing to the device. \value FileOpenError The file could not be opened. \value FilePermissionsError The file could not be accessed. \value FileError Another file error occurred.
Enumerator | |
---|---|
NoError | |
FileWriteError | |
FileOpenError | |
FilePermissionsError | |
FileError |
Definition at line 41 of file qzipwriter_p.h.
|
explicit |
|
explicit |
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.
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.
QZipWriter::CompressionPolicy QZipWriter::compressionPolicy | ( | ) | const |
Returns the currently set compression policy.
QFile::Permissions QZipWriter::creationPermissions | ( | ) | const |
Returns the currently set creation permissions.
QIODevice * QZipWriter::device | ( | ) | const |
bool QZipWriter::exists | ( | ) | const |
bool QZipWriter::isWritable | ( | ) | const |
void QZipWriter::setCompressionPolicy | ( | CompressionPolicy | policy | ) |
Sets the policy for compressing newly added files to the new policy.
void QZipWriter::setCreationPermissions | ( | QFile::Permissions | permissions | ) |
Sets the permissions that will be used for newly added files.
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.