Skip Navigation Links
Skip Navigation LinksHome > ZipArchive > How to Use > API Documentation

CZipFileHeader Class Reference

#include <ZipFileHeader.h>

List of all members.


Public Member Functions

bool CompressionEfficient ()
 CZipFileHeader (const CZipFileHeader &header)
CZipString GetComment () const
WORD GetCommentSize () const
int GetCompressionLevel () const
float GetCompressionRatio ()
WORD GetDataDescriptorSize (bool bConsiderSignature=false) const
WORD GetDataDescriptorSize (const CZipStorage *pStorage) const
ZIP_SIZE_TYPE GetDataSize (bool bUseLocal=false, bool bReal=true) const
DWORD GetEncryptedInfoSize () const
int GetEncryptionMethod () const
CZipString & GetFileName (bool bClearBuffer=true)
DWORD GetLocalSize (bool bReal) const
DWORD GetOriginalAttributes () const
DWORD GetSize () const
CZipStringStoreSettings GetStringStoreSettings ()
DWORD GetSystemAttr ()
int GetSystemCompatibility () const
time_t GetTime () const
bool HasTime ()
bool IsDataDescriptor () const
bool IsDirectory ()
bool IsEncrypted () const
bool IsWinZipAesEncryption () const
CZipFileHeaderoperator= (const CZipFileHeader &header)
int PredictFileNameSize () const
void SetComment (LPCTSTR lpszComment)
void SetFileName (LPCTSTR lpszFileName)
void SetTime (const time_t &ttime)

Public Attributes

CZipExtraField m_aCentralExtraData
 The central extra field.
CZipExtraField m_aLocalExtraData
 The local extra field. Do not modify after you have started compressing the file.
ZIP_SIZE_TYPE m_uComprSize
 The compressed size.
DWORD m_uCrc32
 The crc-32 value.
WORD m_uFlag
 A general purpose bit flag.
WORD m_uInternalAttr
 Internal file attributes.
ZIP_SIZE_TYPE m_uLocalComprSize
 The compressed size written in the local header.
ZIP_SIZE_TYPE m_uLocalUncomprSize
 The uncompressed size written in the local header.
WORD m_uMethod
 The compression method. Can be one of the CZipCompressor::CompressionMethod values.
WORD m_uModDate
 The file last modification date.
WORD m_uModTime
 The file last modification time.
ZIP_SIZE_TYPE m_uOffset
 Relative offset of the local header with respect to CZipFileHeader::m_uVolumeStart.
ZIP_SIZE_TYPE m_uUncomprSize
 The uncompressed size.
WORD m_uVersionMadeBy
 The "made by" version and the system compatibility.
WORD m_uVersionNeeded
 The version needed to extract the file.
ZIP_VOLUME_TYPE m_uVolumeStart
 The volume number at which the compressed file starts.

Static Public Attributes

static char m_gszLocalSignature []
 The local file header signature.
static char m_gszSignature []
 The central file header signature.

Protected Member Functions

bool CheckDataDescriptor (CZipStorage *pStorage) const
bool CheckLengths (bool local) const
bool NeedsDataDescriptor () const
bool NeedsSignatureInDataDescriptor (const CZipStorage *pStorage) const
void PrepareData (int iLevel, bool bSegm)
void PrepareFileName ()
bool Read (CZipCentralDir &centralDir, bool bReadSignature)
bool ReadLocal (CZipCentralDir &centralDir)
void SetSystemAttr (DWORD uAttr)
void SetSystemCompatibility (int iSystemID)
void UpdateFlag (bool bSegm)
void UpdateLocalHeader (CZipStorage *pStorage)
void UpdateLocalZip64 ()
DWORD Write (CZipStorage *pStorage)
void WriteCrc32 (char *pBuf) const
void WriteDataDescriptor (CZipStorage *pStorage)
void WriteLocal (CZipStorage *pStorage)
void WriteSmallDataDescriptor (char *pDest, bool bLocal=true)

Static Protected Member Functions

static bool VerifySignature (CZipAutoBuffer &buf)

Protected Attributes

bool m_bIgnoreCrc32
 A value indicating whether to ignore Crc32 checking or not.
BYTE m_uEncryptionMethod
 The file encryption method. Can be one of the CZipCryptograph::EncryptionMethod values.
DWORD m_uExternalAttr
 External file attributes.
WORD m_uLocalFileNameSize
 The local filename length.

Friends

class CZipArchive
class CZipCentralDir

Detailed Description

Represents a single file stored in a zip archive.

Member Function Documentation

bool CZipFileHeader::CheckDataDescriptor ( CZipStorage pStorage  )  const [protected]

Validates an existing data descriptor after file decompression.

Parameters:
pStorage The storage to read the data descriptor from.
Returns:
true, if the data descriptor is valid; false otherwise.

bool CZipFileHeader::CheckLengths ( bool  local  )  const [inline, protected]

Validates the member fields lengths. The tested fields are: filename, extra fields and comment.

Returns:
false, if any of the lengths exceeds the allowed value.

bool CZipFileHeader::CompressionEfficient (  )  [inline]

Gets a value indicating if the compression is efficient.

Returns:
true if the compression is efficient; false if the file should be stored without the compression instead.

CZipString CZipFileHeader::GetComment (  )  const

Gets the file comment.

Returns:
The file comment.

WORD CZipFileHeader::GetCommentSize (  )  const [inline]

Gets the comment size.

Returns:
The number of characters in the comment not including a terminating NULL character.

int CZipFileHeader::GetCompressionLevel (  )  const

Gets an approximate file compression level.

Returns:
The compression level. May not be the real value used when compressing the file.

float CZipFileHeader::GetCompressionRatio (  )  [inline]

Gets the compression ratio.

Returns:
The compression ratio of the file.

WORD CZipFileHeader::GetDataDescriptorSize ( bool  bConsiderSignature = false  )  const

Gets the data descriptor size as it is required for the current file. Takes into account various factors, such as the need for the data descriptor signature or for the Zip64 format.

Parameters:
bConsiderSignature true, if the data descriptor signature is needed; false otherwise.
Returns:
The required data descriptor size in bytes.

WORD CZipFileHeader::GetDataDescriptorSize ( const CZipStorage pStorage  )  const [inline]

Gets the data descriptor size as it is required for the current file. Takes into account various factors, such as the archive segmentation type, encryption and the need for the Zip64 format.

Parameters:
pStorage The storage to test for segmentation type.
Returns:
The required data descriptor size in bytes.

ZIP_SIZE_TYPE CZipFileHeader::GetDataSize ( bool  bUseLocal = false,
bool  bReal = true 
) const [inline]

Gets the size of the compressed data.

Parameters:
bUseLocal If true, uses m_uLocalComprSize; otherwise uses m_uComprSize;
bReal If true, the returned value does not include the encrypted information size, only the data size. If false, the encrypted information size is added (you should not use this value when the file exists in the archive).
Returns:
The compressed data size in bytes.
See also:
GetEncryptedInfoSize

DWORD CZipFileHeader::GetEncryptedInfoSize (  )  const [inline]

Gets the encrypted information size. The returned value depends on the used encryption method.

Returns:
The encrypted information size in bytes.

int CZipFileHeader::GetEncryptionMethod (  )  const [inline]

Gets the encryption method of the file.

Returns:
The file encryption method. Can be one of the CZipCryptograph::EncryptionMethod values.

CZipString& CZipFileHeader::GetFileName ( bool  bClearBuffer = true  ) 

Gets the filename. If necessary, performs the conversion using the current filename code page. Caches the result of conversion for faster access the next time.

Parameters:
bClearBuffer If true, releases the internal buffer after performing the filename conversion. If false, the internal buffer is not released and both representations of the filename are kept in memory (converted and not converted). This takes more memory, but the conversion does not take place again when the central directory is written back to the archive.
Returns:
The converted filename.
See also:
Unicode Support: Using Non-English Characters in Filenames and Comments

GetStringStoreSettings

CZipStringStoreSettings::m_uNameCodePage

DWORD CZipFileHeader::GetLocalSize ( bool  bReal  )  const

Gets the local header size. Before calling this method, the local information must be up-to-date (see Requesting Information, Predicting Names and Sizes for more information).

Parameters:
bReal If true, uses the real local filename size. If false, predicts the filename size.
Returns:
The local header size in bytes.

DWORD CZipFileHeader::GetOriginalAttributes (  )  const [inline]

Gets the file attributes exactly as they are stored in the archive.

Returns:
The file attributes as they are stored in the archive. No conversion is performed.
Note:
The attributes for Linux are stored shifted left by 16 bits in this field.
See also:
GetSystemAttr

DWORD CZipFileHeader::GetSize (  )  const

Gets the total size of the structure in the central directory.

Returns:
The total size in bytes.

CZipStringStoreSettings CZipFileHeader::GetStringStoreSettings (  )  [inline]

Gets the string store settings for the file.

Returns:
The string store settings.
See also:
Unicode Support: Using Non-English Characters in Filenames and Comments

CZipArchive::GetStringStoreSettings

DWORD CZipFileHeader::GetSystemAttr (  ) 

Gets the file attributes.

Returns:
The file attributes, converted if necessary to be compatible with the current system.
Note:
Throws an exception, if the archive system or the current system is not supported by the ZipArchive Library.
See also:
GetOriginalAttributes

int CZipFileHeader::GetSystemCompatibility (  )  const [inline]

Gets the file system compatibility. External software can use this information e.g. to determine end-of-line format for text files etc. The ZipArchive Library uses it to perform a proper file attributes conversion.

Returns:
The file system compatibility. Can be one of the ZipCompatibility::ZipPlatforms values.
See also:
CZipArchive::GetSystemComatibility

ZipPlatform::GetSystemID

time_t CZipFileHeader::GetTime (  )  const

Gets the file modification time.

Returns:
The modification time.
See also:
SetTime

bool CZipFileHeader::HasTime (  )  [inline]

Returns the value indicating whether the current CZipFileHeader object has the time set or not.

Returns:
true, if the time is set; false otherwise.

bool CZipFileHeader::IsDataDescriptor (  )  const [inline]

Gets a value indicating whether the data descriptor is present or not.

Returns:
true, if the data descriptor is present; false otherwise.

bool CZipFileHeader::IsDirectory (  ) 

Gets a value indicating whether the file represents a directory or not. This method checks the file attributes. If the attributes value is zero, the method checks for the presence of a path separator at the end of the filename. If the path separator is present, the file is assumed to be a directory.

Returns:
true, if the file represents a directory; false otherwise.

bool CZipFileHeader::IsEncrypted (  )  const [inline]

Gets a value indicating if the file is encrypted or not. If the file is encrypted, you need to set the password with the CZipArchive::SetPassword method before decompressing the file.

Returns:
true if the file is encrypted; false otherwise.
See also:
CZipArchive::SetPassword

bool CZipFileHeader::IsWinZipAesEncryption (  )  const [inline]

Gets a value indicating if the file is encrypted using WinZip AES encryption method or not.

Returns:
true, if the file is encrypted using WinZip AES encryption method; false otherwise.

bool CZipFileHeader::NeedsDataDescriptor (  )  const [protected]

Gets a value indicating whether the file needs the data descriptor. The data descriptor is needed when a file is encrypted or the Zip64 format needs to be used.

Returns:
true, if the data descriptor is needed; false otherwise.

int CZipFileHeader::PredictFileNameSize (  )  const [inline]

Predicts the filename size after conversion using the current filename code page.

Returns:
The number of characters not including a terminating NULL character.

void CZipFileHeader::PrepareData ( int  iLevel,
bool  bSegm 
) [protected]

Prepares the data for writing when adding a new file. When Zip64 extensions are required for this file, this method adds Zip64 extra data to m_aLocalExtraData.

Parameters:
iLevel The compression level.
bSegm Set to true, if the archive is segmented; false otherwise.

void CZipFileHeader::PrepareFileName (  )  [inline, protected]

Prepares the filename for writing to the archive.

bool CZipFileHeader::Read ( CZipCentralDir centralDir,
bool  bReadSignature 
) [protected]

Reads the central file header from pStorage and validates the read data.

Parameters:
centralDir The current central directory.
bReadSignature true, if the the central header signature should be read; false otherwise.
Returns:
true, if the read data is consistent; false otherwise.
Note:
Throws exceptions.

bool CZipFileHeader::ReadLocal ( CZipCentralDir centralDir  )  [protected]

Reads the local file header from an archive and validates the read data.

Parameters:
centralDir The current central directory.
Returns:
true, if read data is consistent; false otherwise.
Note:
Throws exceptions.
See also:
CZipArchive::SetIgnoredConsistencyChecks

void CZipFileHeader::SetComment ( LPCTSTR  lpszComment  ) 

Sets the file comment.

Parameters:
lpszComment The file comment.

void CZipFileHeader::SetFileName ( LPCTSTR  lpszFileName  ) 

Sets the filename.

Parameters:
lpszFileName The filename to set.

void CZipFileHeader::SetSystemAttr ( DWORD  uAttr  )  [protected]

Sets the file attributes. To set the attributes of this structure use the CZipArchive::SetFileHeaderAttr method.

Parameters:
uAttr The attributes to set.
Note:
Throws exceptions, if the archive system or the current system is not supported by the ZipArchive Library.
See also:
CZipArchive::SetFileHeaderAttr

GetSystemAttr

void CZipFileHeader::SetSystemCompatibility ( int  iSystemID  )  [inline, protected]

Sets the file system compatibility.

Parameters:
iSystemID The file system compatibility. Can be one of the ZipCompatibility::ZipPlatforms values.
See also:
GetSystemCompatibility

void CZipFileHeader::SetTime ( const time_t &  ttime  ) 

Sets the file modification date.

Parameters:
ttime The date to set. If this value is incorrect, the date defaults to January 1, 1980.
See also:
GetTime

void CZipFileHeader::UpdateFlag ( bool  bSegm  )  [inline, protected]

Updates the general purpose bit flag.

Parameters:
bSegm true, if the current archive is a segmented archive; false otherwise.

void CZipFileHeader::UpdateLocalHeader ( CZipStorage pStorage  )  [protected]

Updates the local header in the archive after is has already been written.

Parameters:
pStorage The storage to update the data descriptor in.

void CZipFileHeader::UpdateLocalZip64 (  )  [protected]

Creates Zip64 extra data in the local extra field, if needed.

Note:
Throws exceptions.

static bool CZipFileHeader::VerifySignature ( CZipAutoBuffer &  buf  )  [inline, static, protected]

Verifies the central header signature.

Parameters:
buf The buffer that contains the signature to verify.
Returns:
true, if the signature is valid; false otherwise.

DWORD CZipFileHeader::Write ( CZipStorage pStorage  )  [protected]

Writes the central file header to pStorage.

Parameters:
pStorage The storage to write the central file header to.
Returns:
The size of the file header.
Note:
Throws exceptions.

void CZipFileHeader::WriteCrc32 ( char *  pBuf  )  const [protected]

Writes the Crc32 to pBuf.

Parameters:
pBuf The buffer to write the Crc32 to. Must have be of at least 4 bytes size.

void CZipFileHeader::WriteDataDescriptor ( CZipStorage pStorage  )  [protected]

Writes the data descriptor taking into account the Zip64 format.

Parameters:
pStorage The storage to write the data descriptor to.

void CZipFileHeader::WriteLocal ( CZipStorage pStorage  )  [protected]

Writes the local file header to the pStorage. The filename and extra field are the same as those that will be stored in the central directory.

Parameters:
pStorage The storage to write the local file header to.
Note:
Throws exceptions.

void CZipFileHeader::WriteSmallDataDescriptor ( char *  pDest,
bool  bLocal = true 
) [protected]

Writes the data descriptor.

Parameters:
pDest The buffer to receive the data.
bLocal Set to true, if the local sizes are used; false otherwise.


Member Data Documentation

The local extra field. Do not modify after you have started compressing the file.

A value indicating whether to ignore Crc32 checking or not.

The local file header signature.

The central file header signature.

The compressed size.

The crc-32 value.

The file encryption method. Can be one of the CZipCryptograph::EncryptionMethod values.

External file attributes.

A general purpose bit flag.

Internal file attributes.

The compressed size written in the local header.

The local filename length.

The uncompressed size written in the local header.

The compression method. Can be one of the CZipCompressor::CompressionMethod values.

The file last modification date.

The file last modification time.

Relative offset of the local header with respect to CZipFileHeader::m_uVolumeStart.

The uncompressed size.

The "made by" version and the system compatibility.

The version needed to extract the file.

The volume number at which the compressed file starts.


The documentation for this class was generated from the following file:
Back To Top Up