CZipFileHeader Class Reference

Representation of a single file stored in the zip archive. More...

#include <ZipFileHeader.h>

List of all members.

Public Member Functions

WORD GetFileNameSize () const
WORD GetCommentSize () const
WORD GetExtraFieldSize () const
CZipString GetFileName () const
bool SetFileName (LPCTSTR lpszFileName)
 Set the filename.
CZipString GetComment () const
bool SetComment (LPCTSTR lpszComment)
 Set the file comment.
bool IsDataDescr () const
DWORD GetEffComprSize ()
bool CompressionEfficient ()
float GetCompressionRatio ()
bool IsEncrypted () const
void SetTime (const time_t &ttime)
 Set m_uModDate, m_uModTime (file modification time).
time_t GetTime () const
DWORD GetSize () const
DWORD GetLocalSize () const
int GetSystemCompatibility () const
DWORD GetSystemAttr () const
DWORD GetOriginalAttributes () const
bool IsDirectory () const

Public Attributes

char m_szSignature [4]
 central file header signature
WORD m_uVersionMadeBy
 version made by and system compatibility
WORD m_uVersionNeeded
 version needed to extract
WORD m_uFlag
 general purpose bit flag
WORD m_uMethod
 compression method
WORD m_uModTime
 last mod file time
WORD m_uModDate
 last mod file date
DWORD m_uCrc32
 crc-32
DWORD m_uComprSize
 compressed size
DWORD m_uUncomprSize
 uncompressed size
WORD m_uDiskStart
 disk number start
WORD m_uInternalAttr
 internal file attributes
DWORD m_uOffset
 relative offset of local header
CZipAutoBuffer m_pExtraField
 extra field (variable size)

Static Public Attributes

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

Protected Member Functions

DWORD GetLocalSize (bool bReal) const
void SetSystemCompatibility (int iSystemID)
 Set the system compatibility of the file.
void SetSystemAttr (DWORD uAttr)
 Set the system attributes if you wish to set the attributes of this structure use CZipArchive::SetFileHeaderAttr().
void SetVersion (WORD uVersion)
 Set the version made by number.
void GetCrcAndSizes (char *pBuffer) const
 Fill the buffer with the current values of crc and compressed and uncompressed sizes of the file.
bool CheckCrcAndSizes (char *pBuf) const
 Check whether the actual values of crc and compressed and uncompressed sizes of the file are the same as defined in the file header.
bool PrepareData (int iLevel, bool bSpan, bool bEncrypted)
 Prepare the data for the class while adding a new file.
void WriteLocal (CZipStorage &storage)
 Write the local file header to the storage.
bool Read (CZipStorage *pStorage)
 Read the file header from the central directory record from pStorage.
bool ReadLocal (CZipStorage *pStorage)
 Read the local file header from pStorage and check for consistency.
DWORD Write (CZipStorage *pStorage)
 Write the file header to pStorage.

Protected Attributes

DWORD m_uExternalAttr
 external file attributes
WORD m_uLocalFileNameSize
 local filename length
WORD m_uLocalExtraFieldSize
 local extra field length
CZipAutoBuffer m_pszFileName
 a filename
CZipAutoBuffer m_pszComment
 a file comment

Friends

class CZipCentralDir
class CZipArchive
void FileNameUpdate (CZipFileHeader &, bool, bool)
 Convert the filename of the file inside archive.


Detailed Description

Representation of a single file stored in the zip archive.

Modify all the class attributes BEFORE adding a file to and archive ( using CZipArchive::OpenNewFile ). It is not possible to modify the data of the existing files in the archive (it would mean updating all the information in the local headers and the offsets would be changed as well when the filename would changed its size)

Definition at line 45 of file ZipFileHeader.h.


Member Function Documentation

bool CZipFileHeader::CheckCrcAndSizes char *  pBuf  )  const [protected]
 

Check whether the actual values of crc and compressed and uncompressed sizes of the file are the same as defined in the file header.

Parameters:
pBuf buffer with the mentioned data
Returns:
true if they are the same; otherwise false;

bool CZipFileHeader::CompressionEfficient  )  [inline]
 

Returns:
false if the file should be stored instead of being compressed

Definition at line 126 of file ZipFileHeader.h.

CZipString CZipFileHeader::GetComment  )  const
 

Returns:
the file comment

WORD CZipFileHeader::GetCommentSize  )  const [inline]
 

Returns:
the comment size in characters (without NULL)

Definition at line 70 of file ZipFileHeader.h.

float CZipFileHeader::GetCompressionRatio  )  [inline]
 

Returns:
the compression ratio of the file

Definition at line 137 of file ZipFileHeader.h.

DWORD CZipFileHeader::GetEffComprSize  )  [inline]
 

Returns:
get the effective compressed size: if the file is encrypted, return less by the size of the encryption header

Definition at line 118 of file ZipFileHeader.h.

WORD CZipFileHeader::GetExtraFieldSize  )  const [inline]
 

Returns:
the extra field size in characters

Definition at line 75 of file ZipFileHeader.h.

CZipString CZipFileHeader::GetFileName  )  const
 

Returns:
the filename

Referenced by CZipCentralDir::GetProperHeaderFileName().

WORD CZipFileHeader::GetFileNameSize  )  const [inline]
 

Returns:
the filename size in characters (without NULL)

Definition at line 65 of file ZipFileHeader.h.

DWORD CZipFileHeader::GetLocalSize bool  bReal  )  const [protected]
 

Parameters:
bReal if true return the local file header size as it is (a call to CZipCentralDir::UpdateLocal before is required), otherwise return the size as it is when CZipFileHeader::WriteLocal is executed (in this case the filename and extra field are copied from the central directory)
Returns:
the total size of the local structure depending on the bReal parameter

DWORD CZipFileHeader::GetLocalSize  )  const [inline]
 

Returns:
the total size of the local header as it is reported by GetLocalSize(bool) const with bReal parameter set to false
See also:
GetLocalSize(bool) const

Definition at line 196 of file ZipFileHeader.h.

DWORD CZipFileHeader::GetOriginalAttributes  )  const [inline]
 

Returns:
the original attributes as stored in the archive (without performing any conversion)

Definition at line 231 of file ZipFileHeader.h.

DWORD CZipFileHeader::GetSize  )  const
 

Returns:
the total size of the structure in the central directory

DWORD CZipFileHeader::GetSystemAttr  )  const
 

Returns:
the attributes of the file converted to the current system compatible value
Note:
  • Throws exception if the archive system or the current system is not supported by the ZipArchive library.
  • (only Linux version): After obtaining the attributes, you need to shift them right by 16

int CZipFileHeader::GetSystemCompatibility  )  const [inline]
 

Returns:
the system compatibility of the current file as the one of ZipCompatibility::ZipPlatforms values; usually the same as CZipArchive::GetSystemComatibility. Software can use this information e.g. to determine the line record format for text files etc. ZipArchive library uses it to perform a proper attributes conversion.
See also:
CZipArchive::GetSystemComatibility

ZipPlatform::GetSystemID

Definition at line 212 of file ZipFileHeader.h.

time_t CZipFileHeader::GetTime  )  const
 

Returns:
the modification time
See also:
SetTime

bool CZipFileHeader::IsDataDescr  )  const [inline]
 

Returns:
true if the data descriptor is present

Definition at line 111 of file ZipFileHeader.h.

bool CZipFileHeader::IsDirectory  )  const
 

Returns:
true, if this object represents a directory; otherwise false; If m_uExternalAttr value is zero, the function check for a presence of a path separator at the end of the file name. If it is present, it is assumed to be a directory.

bool CZipFileHeader::IsEncrypted  )  const [inline]
 

Returns:
if the file is encrypted ( a password is needed to extract this file)
See also:
CZipArchive::SetPassword

Definition at line 146 of file ZipFileHeader.h.

bool CZipFileHeader::PrepareData int  iLevel,
bool  bSpan,
bool  bEncrypted
[protected]
 

Prepare the data for the class while adding a new file.

Called by CZipArchive::OpenNewFile

Parameters:
iLevel a compression level
bSpan true, if the data descriptor will be present because of spanning archive
bEncrypted true, if the file will be encrypted
Returns:
true if the sizes of the filename, extra field and comments does not exceed unsigned short maximum value; otherwise false;

bool CZipFileHeader::Read CZipStorage pStorage  )  [protected]
 

Read the file header from the central directory record from pStorage.

Parameters:
*pStorage 
Returns:
true if the whole file header is on one disk in a multi-disk archive; otherwise false;
Note:
Throws exceptions.

bool CZipFileHeader::ReadLocal CZipStorage pStorage  )  [protected]
 

Read the local file header from pStorage and check for consistency.

Parameters:
*pStorage 
Returns:
false, if something goes wrong; otherwise true;
Note:
Throws exceptions.

bool CZipFileHeader::SetComment LPCTSTR  lpszComment  ) 
 

Set the file comment.

Parameters:
lpszComment 
Returns:
true, if conversion from UNICODE to single byte was successful (or if there was no conversion needed or possible); otherwise false;

bool CZipFileHeader::SetFileName LPCTSTR  lpszFileName  ) 
 

Set the filename.

Parameters:
lpszFileName 
Returns:
true, if conversion from UNICODE to single byte was successful (or if there was no conversion needed or possible); otherwise false;

void CZipFileHeader::SetSystemAttr DWORD  uAttr  )  [protected]
 

Set the system attributes if you wish to set the attributes of this structure use CZipArchive::SetFileHeaderAttr().

Parameters:
uAttr 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

SetSystemCompatibility

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

Set the system compatibility of the file.

Parameters:
iSystemID one of ZipCompatibility::ZipPlatforms values
See also:
CZipArchive::GetSystemCompatibility

Definition at line 258 of file ZipFileHeader.h.

void CZipFileHeader::SetTime const time_t &  ttime  ) 
 

Set m_uModDate, m_uModTime (file modification time).

If the ttime is not correct, the date defaults to January 1, 1980

Parameters:
ttime 
See also:
GetTime

DWORD CZipFileHeader::Write CZipStorage pStorage  )  [protected]
 

Write the file header to pStorage.

Parameters:
*pStorage 
Returns:
the size of the file header
Note:
Throws exceptions.

void CZipFileHeader::WriteLocal CZipStorage storage  )  [protected]
 

Write the local file header to the storage.

The filename and extra field are copied from the central directory.

Parameters:
storage 
Note:
Throws exceptions.


Friends And Related Function Documentation

void FileNameUpdate CZipFileHeader ,
bool  ,
bool 
[friend]
 

Convert the filename of the file inside archive.

This conversion may not change the size of the filename, otherwise an error may occur in CZipFileHeader::ReadLocal while comparing the filename sizes.

Parameters:
header the file header to have the filename converted
bFromZip if true convert the path from the from it is stored in the archive to the current system compatible form; otherwise vice-versa.
bOemConversion if true, the OEM conversion on the filename is performed (valid only under Windows platform)
See also:
CZipCentralDir::ConvertFileName


The documentation for this class was generated from the following file:
ZipArchive Copyright © 2000 - 2006 Tadeusz Dracz . Generated at Fri Apr 7 13:55:25 2006.