QuaZipNewInfo Struct Reference

Information about a file to be created. More...

`#include <quazipnewinfo.h>`

List of all members.

## Public Member Functions

| QuaZipNewInfo (const QString &name)
| Constructs QuaZipNewInfo instance.
| QuaZipNewInfo (const QString &name, const QString &file)
| Constructs QuaZipNewInfo instance.
void | setFileDateTime (const QString &file)
| Sets the file timestamp from the existing file.
void | setFilePermissions (const QString &file)
| Sets the file permissions from the existing file.
void | setPermissions (QFile::Permissions permissions)
| Sets the file permissions.

## Public Attributes

QString | name
| File name.
QDateTime | dateTime
| File timestamp.
quint16 | internalAttr
| File internal attributes.
quint32 | externalAttr
| File external attributes.
QString | comment
| File comment.
QByteArray | extraLocal
| File local extra field.
QByteArray | extraGlobal
| File global extra field.
ulong | uncompressedSize
| Uncompressed file size.

## Detailed Description

Information about a file to be created.

This structure holds information about a file to be created inside ZIP archive. At least name should be set to something correct before passing this structure to QuaZipFile::open(OpenMode,const QuaZipNewInfo&,int,int,bool).

## Constructor & Destructor Documentation

QuaZipNewInfo::QuaZipNewInfo | ( | const QString & | name | ) |

Constructs QuaZipNewInfo instance.

Initializes name with name, dateTime with current date and time. Attributes are initialized with zeros, comment and extra field with null values.

QuaZipNewInfo::QuaZipNewInfo | ( | const QString & | name,
|  | const QString & | file
| ) |  |

Constructs QuaZipNewInfo instance.

Initializes name with name. Timestamp and permissions are taken from the specified file. If the file does not exists or its timestamp is inaccessible (e. g. you do not have read permission for the directory file in), uses current time and zero permissions. Other attributes are initialized with zeros, comment and extra field with null values.

See also:
  setFileDateTime()

References dateTime.

## Member Function Documentation

void QuaZipNewInfo::setFileDateTime | ( | const QString & | file | ) |

Sets the file timestamp from the existing file.

Use this function to set the file timestamp from the existing file. Use it like this:

     QuaZipFile zipFile(&zip);
     QFile file("file-to-add");
     file.open(QIODevice::ReadOnly);
     QuaZipNewInfo info("file-name-in-archive");
     info.setFileDateTime("file-to-add"); // take the timestamp from file
     zipFile.open(QIODevice::WriteOnly, info);

This function does not change dateTime if some error occured (e. g. file is inaccessible).

References dateTime.

void QuaZipNewInfo::setFilePermissions | ( | const QString & | file | ) |

Sets the file permissions from the existing file.

Takes permissions from the file and sets the high 16 bits of external attributes. Uses QFileInfo to get permissions on all platforms.

void QuaZipNewInfo::setPermissions | ( | QFile::Permissions | permissions | ) |

Sets the file permissions.

Modifies the highest 16 bits of external attributes. The type part is set to dir if the name ends with a slash, and to regular file otherwise.

References name.

## Member Data Documentation

QString QuaZipNewInfo::name

File name.

This field holds file name inside archive, including path relative to archive root.

Referenced by QuaZipFile::open(), and setPermissions().

QDateTime QuaZipNewInfo::dateTime

File timestamp.

This is the last file modification date and time. Will be stored in the archive central directory. It is a good practice to set it to the source file timestamp instead of archive creating time. Use setFileDateTime() or QuaZipNewInfo(const QString&, const QString&).

Referenced by QuaZipFile::open(), QuaZipNewInfo(), and setFileDateTime().

quint32 QuaZipNewInfo::externalAttr

File external attributes.

The highest 16 bits contain Unix file permissions and type (dir or file). The constructor QuaZipNewInfo(const QString&, const QString&) takes permissions from the provided file.

Referenced by QuaZipFile::open().

QString QuaZipNewInfo::comment

File comment.

Will be encoded using QuaZip::getCommentCodec().

Referenced by QuaZipFile::open().

ulong QuaZipNewInfo::uncompressedSize

Uncompressed file size.

This is only needed if you are using raw file zipping mode, i. e. adding precompressed file in the zip archive.

Referenced by QuaZipFile::open().

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

- quazip/quazipnewinfo.h
- quazip/quazipnewinfo.cpp