QuaZIP quazip-0-7-2
Public Member Functions | Public Attributes
QuaZipNewInfo Struct Reference

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

#include <quazipnewinfo.h>

Collaboration diagram for QuaZipNewInfo:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 QuaZipNewInfo (const QString &name)
 Constructs QuaZipNewInfo instance.
 QuaZipNewInfo (const QString &name, const QString &file)
 Constructs QuaZipNewInfo instance.
 QuaZipNewInfo (const QuaZipFileInfo &existing)
 Initializes the new instance from existing file info.
 QuaZipNewInfo (const QuaZipFileInfo64 &existing)
 Initializes the new instance from existing file info.
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.
void setFileNTFSTimes (const QString &fileName)
 Sets the NTFS times from an existing file.
void setFileNTFSmTime (const QDateTime &mTime, int fineTicks=0)
 Sets the NTFS modification time.
void setFileNTFSaTime (const QDateTime &aTime, int fineTicks=0)
 Sets the NTFS access time.
void setFileNTFScTime (const QDateTime &cTime, int fineTicks=0)
 Sets the NTFS creation time.

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).

Zip64 support of this structure is slightly limited: in the raw mode (when a pre-compressed file is written into a ZIP file as-is), it is necessary to specify the uncompressed file size and the appropriate field is 32 bit. Since the raw mode is used extremely rare, there is no real need to have a separate QuaZipNewInfo64 structure like QuaZipFileInfo64. It may be added in the future though, if there is a demand for the raw mode with zip64 archives.


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 QDateTime::currentDateTime(), dateTime, QFileInfo::exists(), QFileInfo::isDir(), QFileInfo::lastModified(), and QFileInfo::permissions().

QuaZipNewInfo::QuaZipNewInfo ( const QuaZipFileInfo existing)

Initializes the new instance from existing file info.

Mainly used when copying files between archives.

Both extra fields are initialized to existing.extra. QuaZipNewInfo

Parameters:
existing
QuaZipNewInfo::QuaZipNewInfo ( const QuaZipFileInfo64 existing)

Initializes the new instance from existing file info.

Mainly used when copying files between archives.

Both extra fields are initialized to existing.extra. QuaZipNewInfo

Parameters:
existing

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, QFileInfo::exists(), and QFileInfo::lastModified().

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.

References QFileInfo::isDir(), QFileInfo::permissions(), and QFileDevice::Permissions.

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 QString::endsWith(), and name.

void QuaZipNewInfo::setFileNTFSTimes ( const QString fileName)

Sets the NTFS times from an existing file.

If the file doesn't exist, a warning is printed to the stderr and nothing is done. Otherwise, all three times, as reported by QFileInfo::lastModified(), QFileInfo::lastRead() and QFileInfo::created(), are written to the NTFS extra field record.

The NTFS record is written to both the local and the global extra fields, updating the existing record if there is one, or creating a new one and appending it to the end of each extra field.

The microseconds will be zero, as they aren't reported by QFileInfo.

Parameters:
fileName

References QByteArray::constData(), QFileInfo::created(), QFileInfo::exists(), QFileInfo::lastModified(), QFileInfo::lastRead(), setFileNTFSaTime(), setFileNTFScTime(), setFileNTFSmTime(), and QString::toUtf8().

void QuaZipNewInfo::setFileNTFSmTime ( const QDateTime mTime,
int  fineTicks = 0 
)

Sets the NTFS modification time.

The time is written into the NTFS record in both the local and the global extra fields, updating the existing record if there is one, or creating a new one and appending it to the end of each extra field. When updating an existing record, all other fields are left intact.

Parameters:
mTimeThe new modification time.
fineTicksThe fractional part of milliseconds, in 100-nanosecond ticks (i. e. 9999 ticks = 999.9 microsecond). Values greater than 9999 will add milliseconds or even seconds, but this can be confusing and therefore is discouraged.

References extraGlobal, and extraLocal.

Referenced by setFileNTFSTimes().

void QuaZipNewInfo::setFileNTFSaTime ( const QDateTime aTime,
int  fineTicks = 0 
)

Sets the NTFS access time.

The time is written into the NTFS record in both the local and the global extra fields, updating the existing record if there is one, or creating a new one and appending it to the end of each extra field. When updating an existing record, all other fields are left intact.

Parameters:
aTimeThe new access time.
fineTicksThe fractional part of milliseconds, in 100-nanosecond ticks (i. e. 9999 ticks = 999.9 microsecond). Values greater than 9999 will add milliseconds or even seconds, but this can be confusing and therefore is discouraged.

References extraGlobal, and extraLocal.

Referenced by setFileNTFSTimes().

void QuaZipNewInfo::setFileNTFScTime ( const QDateTime cTime,
int  fineTicks = 0 
)

Sets the NTFS creation time.

The time is written into the NTFS record in both the local and the global extra fields, updating the existing record if there is one, or creating a new one and appending it to the end of each extra field. When updating an existing record, all other fields are left intact.

Parameters:
cTimeThe new creation time.
fineTicksThe fractional part of milliseconds, in 100-nanosecond ticks (i. e. 9999 ticks = 999.9 microsecond). Values greater than 9999 will add milliseconds or even seconds, but this can be confusing and therefore is discouraged.

References extraGlobal, and extraLocal.

Referenced by setFileNTFSTimes().


Member Data Documentation

File name.

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

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

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().

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().

File comment.

Will be encoded using QuaZip::getCommentCodec().

Referenced by QuaZipFile::open().

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: