#include <ZipFileHeader.h>
Classes | |
struct | StringWithBuffer |
Public Types | |
enum | StateFlags { sfNone = 0x00, sfCustomUnicode = 0x10, sfModified = 0x20 } |
Public Member Functions | |
bool | CompressionEfficient () |
CZipFileHeader (const CZipFileHeader &header) | |
const CZipString & | GetComment (bool bClearBuffer=false) |
int | GetCompressionLevel () const |
float | GetCompressionRatio () |
WORD | GetDataDescriptorSize (bool bConsiderSignature=false) const |
WORD | GetDataDescriptorSize (const CZipStorage *pStorage) const |
ZIP_SIZE_TYPE | GetDataSize (bool bReal) const |
DWORD | GetEncryptedInfoSize () const |
int | GetEncryptionMethod () const |
const CZipString & | GetFileName (bool bClearBuffer=true) |
DWORD | GetLocalSize (bool bReal) const |
DWORD | GetOriginalAttributes () const |
DWORD | GetSize () const |
const ZipArchiveLib::CBitFlag & | GetState () const |
CZipStringStoreSettings | GetStringStoreSettings () |
DWORD | GetSystemAttr () |
int | GetSystemCompatibility () const |
time_t | GetTime () const |
bool | HasTime () const |
bool | IsDataDescriptor () const |
bool | IsDirectory () |
bool | IsEncrypted () const |
bool | IsModified () const |
bool | IsWinZipAesEncryption () const |
CZipFileHeader & | operator= (const CZipFileHeader &header) |
int | PredictCommentSize () const |
int | PredictFileNameSize () const |
bool | SetComment (LPCTSTR lpszComment) |
bool | SetFileName (LPCTSTR lpszFileName) |
bool | SetSystemAttr (DWORD uAttr) |
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 it after you 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. It 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. | |
unsigned char | m_uVersionMadeBy |
The version of the software that created the archive. | |
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 | |
void | AdjustLocalComprSize (ZIP_SIZE_TYPE &uLocalComprSize) |
void | AdjustLocalComprSize () |
bool | CheckDataDescriptor (CZipStorage *pStorage) const |
bool | CheckLengths (bool local) const |
CZipFileHeader (CZipCentralDir *pCentralDir) | |
bool | NeedsDataDescriptor () const |
bool | NeedsSignatureInDataDescriptor (const CZipStorage *pStorage) const |
void | PrepareData (int iLevel, bool bSegm) |
void | PrepareStringBuffers () |
bool | Read (bool bReadSignature) |
bool | ReadLocal (CZipCentralDir *pCentralDir) |
void | SetSystemCompatibility (int iSystemID, bool bUpdateAttr=false) |
void | UpdateFlag (bool bSegm) |
void | UpdateLocalHeader (CZipStorage *pStorage) |
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 |
The value indicating whether to ignore Crc32 checking. | |
CZipCentralDir * | m_pCentralDir |
The parent central directory. It can be NULL when the header is not a part of central directory. | |
BYTE | m_uEncryptionMethod |
The file encryption method. It can be one of the CZipCryptograph::EncryptionMethod values. | |
DWORD | m_uExternalAttr |
External file attributes. | |
WORD | m_uLocalFileNameSize |
The local filename length. | |
DWORD | m_uLocalHeaderSize |
Friends | |
class | CZipArchive |
class | CZipCentralDir |
Definition at line 45 of file ZipFileHeader.h.
File header state flags.
sfNone | No special flags set. |
sfCustomUnicode | The header uses custom Unicode functionality. |
sfModified | The file has been modified. |
Definition at line 58 of file ZipFileHeader.h.
void CZipFileHeader::AdjustLocalComprSize | ( | ZIP_SIZE_TYPE & | uLocalComprSize | ) | [inline, protected] |
Adjusts the local compressed size.
uLocalComprSize | The value to adjust. |
Definition at line 735 of file ZipFileHeader.h.
void CZipFileHeader::AdjustLocalComprSize | ( | ) | [inline, protected] |
Adjusts the local compressed size.
Definition at line 724 of file ZipFileHeader.h.
bool CZipFileHeader::CheckDataDescriptor | ( | CZipStorage * | pStorage | ) | const [protected] |
Validates an existing data descriptor after file decompression.
pStorage | The storage to read the data descriptor from. |
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.
false
, if any of the lengths exceeds the allowed value. Definition at line 651 of file ZipFileHeader.h.
bool CZipFileHeader::CompressionEfficient | ( | ) | [inline] |
Returns the value indicating whether the compression is efficient.
true
if the compression is efficient; false
if the file should be stored without the compression instead. Definition at line 284 of file ZipFileHeader.h.
const CZipString& CZipFileHeader::GetComment | ( | bool | bClearBuffer = false |
) |
Returns the file comment.
bClearBuffer | If true , releases the internal buffer after performing the comment conversion. If false , the internal buffer is not released and both representations of the comment 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. |
int CZipFileHeader::GetCompressionLevel | ( | ) | const |
Returns an approximate file compression level.
float CZipFileHeader::GetCompressionRatio | ( | ) | [inline] |
Returns the compression ratio.
Definition at line 298 of file ZipFileHeader.h.
WORD CZipFileHeader::GetDataDescriptorSize | ( | bool | bConsiderSignature = false |
) | const |
Returns 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.
bConsiderSignature | true , if the data descriptor signature is needed; false otherwise. |
WORD CZipFileHeader::GetDataDescriptorSize | ( | const CZipStorage * | pStorage | ) | const [inline] |
Returns 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.
pStorage | The storage to test for the segmentation type. |
Definition at line 208 of file ZipFileHeader.h.
ZIP_SIZE_TYPE CZipFileHeader::GetDataSize | ( | bool | bReal | ) | const [inline] |
Returns the size of the compressed data.
bReal | Set to true when calling for a file already in an archive. Set to false when the header is not a part of the archive. |
Definition at line 239 of file ZipFileHeader.h.
DWORD CZipFileHeader::GetEncryptedInfoSize | ( | ) | const [inline] |
Returns the encrypted information size. The returned value depends on the used encryption method.
Definition at line 251 of file ZipFileHeader.h.
int CZipFileHeader::GetEncryptionMethod | ( | ) | const [inline] |
Returns the encryption method of the file.
Definition at line 440 of file ZipFileHeader.h.
const CZipString& CZipFileHeader::GetFileName | ( | bool | bClearBuffer = true |
) |
Returns the filename. If necessary, performs the conversion using the current filename code page. Caches the result of conversion for faster access the next time.
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. |
DWORD CZipFileHeader::GetLocalSize | ( | bool | bReal | ) | const |
Returns 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).
bReal | If true , uses the real local filename size. If false , predicts the filename size. |
DWORD CZipFileHeader::GetOriginalAttributes | ( | ) | const [inline] |
Returns the file attributes exactly as they are stored in the archive.
Definition at line 389 of file ZipFileHeader.h.
DWORD CZipFileHeader::GetSize | ( | ) | const |
Returns the total size of this structure in the central directory.
const ZipArchiveLib::CBitFlag& CZipFileHeader::GetState | ( | ) | const [inline] |
Returns the state flags.
Definition at line 493 of file ZipFileHeader.h.
CZipStringStoreSettings CZipFileHeader::GetStringStoreSettings | ( | ) | [inline] |
Returns the current string store settings.
Definition at line 415 of file ZipFileHeader.h.
DWORD CZipFileHeader::GetSystemAttr | ( | ) |
Returns the file attributes.
int CZipFileHeader::GetSystemCompatibility | ( | ) | const [inline] |
Returns 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.
Definition at line 342 of file ZipFileHeader.h.
time_t CZipFileHeader::GetTime | ( | ) | const |
bool CZipFileHeader::HasTime | ( | ) | const [inline] |
Returns the value indicating whether the current CZipFileHeader object has the time set.
true
, if the time is set; false
otherwise. Definition at line 467 of file ZipFileHeader.h.
bool CZipFileHeader::IsDataDescriptor | ( | ) | const [inline] |
Returns the value indicating whether the data descriptor is present.
true
, if the data descriptor is present; false
otherwise. Definition at line 195 of file ZipFileHeader.h.
bool CZipFileHeader::IsDirectory | ( | ) |
Returns the value indicating whether the file represents a directory. 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.
true
, if the file represents a directory; false
otherwise. bool CZipFileHeader::IsEncrypted | ( | ) | const [inline] |
Returns the value indicating whether the file is encrypted. If the file is encrypted, you need to set the password with the CZipArchive::SetPassword method before decompressing the file.
true
if the file is encrypted; false
otherwise.Definition at line 432 of file ZipFileHeader.h.
bool CZipFileHeader::IsModified | ( | ) | const [inline] |
Returns the value indicating whether the file was modified.
true
, if the file was modified; false
otherwise.Definition at line 481 of file ZipFileHeader.h.
bool CZipFileHeader::IsWinZipAesEncryption | ( | ) | const [inline] |
Returns the value indicating whether the file is encrypted using WinZip AES encryption method.
true
, if the file is encrypted using WinZip AES encryption method; false
otherwise. Definition at line 448 of file ZipFileHeader.h.
bool CZipFileHeader::NeedsDataDescriptor | ( | ) | const [protected] |
Returns the 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.
true
, if the data descriptor is needed; false
otherwise. bool CZipFileHeader::NeedsSignatureInDataDescriptor | ( | const CZipStorage * | pStorage | ) | const [inline, protected] |
Returns the value indicating whether the signature in the data descriptor is needed.
pStorage | The current storage. |
true
, if the signature is needed; false
otherwise. Definition at line 708 of file ZipFileHeader.h.
int CZipFileHeader::PredictCommentSize | ( | ) | const [inline] |
Predicts a file comment size.
NULL
character. Definition at line 98 of file ZipFileHeader.h.
int CZipFileHeader::PredictFileNameSize | ( | ) | const [inline] |
Predicts the filename size after conversion using the current filename code page.
NULL
character. Definition at line 81 of file ZipFileHeader.h.
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.
iLevel | The compression level. | |
bSegm | Set to true , if the archive is segmented; false otherwise. |
void CZipFileHeader::PrepareStringBuffers | ( | ) | [inline, protected] |
Prepares the filename for writing to the archive.
Definition at line 557 of file ZipFileHeader.h.
bool CZipFileHeader::Read | ( | bool | bReadSignature | ) | [protected] |
Reads the central file header from pStorage and validates the read data.
bReadSignature | true , if the the central header signature should be read; false otherwise. |
true
, if the read data is consistent; false
otherwise. bool CZipFileHeader::ReadLocal | ( | CZipCentralDir * | pCentralDir | ) | [protected] |
Reads the local file header from the archive and validates the read data.
pCentralDir | Used when the archive was opened with CZipArchive::OpenFrom method. Points to the original central directory. |
true
, if the data read is consistent; false
otherwise.bool CZipFileHeader::SetComment | ( | LPCTSTR | lpszComment | ) |
Sets the file comment.
lpszComment | The file comment. |
true
, if the method succeeded; false
, if the current state of the archive is invalid for this method to be called.bool CZipFileHeader::SetFileName | ( | LPCTSTR | lpszFileName | ) |
Sets the filename.
The actual renaming of the file inside of the archive depends on the current commit mode.
lpszFileName | The filename to set. |
true
, if the method succeeded; false
, if the current state of the archive is invalid for this method to be called.bool CZipFileHeader::SetSystemAttr | ( | DWORD | uAttr | ) |
Sets the file attributes.
uAttr | The attributes to set. |
void CZipFileHeader::SetSystemCompatibility | ( | int | iSystemID, | |
bool | bUpdateAttr = false | |||
) | [inline, protected] |
Sets the file system compatibility.
iSystemID | The file system compatibility. It can be one of the ZipCompatibility::ZipPlatforms values. | |
bUpdateAttr | If true , the attributes will be converted to the new system; false otherwise. |
Definition at line 539 of file ZipFileHeader.h.
void CZipFileHeader::SetTime | ( | const time_t & | ttime | ) |
Sets the file modification date.
ttime | The date to set. If this value is incorrect, the date defaults to January 1, 1980. |
void CZipFileHeader::UpdateFlag | ( | bool | bSegm | ) | [inline, protected] |
Updates the general purpose bit flag.
bSegm | true , if the current archive is a segmented archive; false otherwise. |
Definition at line 760 of file ZipFileHeader.h.
void CZipFileHeader::UpdateLocalHeader | ( | CZipStorage * | pStorage | ) | [protected] |
Updates the local header in the archive after is has already been written.
pStorage | The storage to update the data descriptor in. |
static bool CZipFileHeader::VerifySignature | ( | CZipAutoBuffer & | buf | ) | [inline, static, protected] |
Verifies the central header signature.
buf | The buffer that contains the signature to verify. |
true
, if the signature is valid; false
otherwise. Definition at line 749 of file ZipFileHeader.h.
DWORD CZipFileHeader::Write | ( | CZipStorage * | pStorage | ) | [protected] |
Writes the central file header to pStorage.
pStorage | The storage to write the central file header to. |
void CZipFileHeader::WriteCrc32 | ( | char * | pBuf | ) | const [protected] |
Writes the Crc32 to pBuf.
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.
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.
pStorage | The storage to write the local file header to. |
void CZipFileHeader::WriteSmallDataDescriptor | ( | char * | pDest, | |
bool | bLocal = true | |||
) | [protected] |
Writes the data descriptor.
pDest | The buffer to receive the data. | |
bLocal | Set to true , if the local sizes are used; false otherwise. |
The local extra field. Do not modify it after you started compressing the file.
Definition at line 514 of file ZipFileHeader.h.
bool CZipFileHeader::m_bIgnoreCrc32 [protected] |
The value indicating whether to ignore Crc32 checking.
Definition at line 520 of file ZipFileHeader.h.
char CZipFileHeader::m_gszLocalSignature[] [static] |
char CZipFileHeader::m_gszSignature[] [static] |
CZipCentralDir* CZipFileHeader::m_pCentralDir [protected] |
The parent central directory. It can be NULL
when the header is not a part of central directory.
Definition at line 523 of file ZipFileHeader.h.
ZIP_SIZE_TYPE CZipFileHeader::m_uComprSize |
DWORD CZipFileHeader::m_uCrc32 |
BYTE CZipFileHeader::m_uEncryptionMethod [protected] |
The file encryption method. It can be one of the CZipCryptograph::EncryptionMethod values.
Definition at line 519 of file ZipFileHeader.h.
DWORD CZipFileHeader::m_uExternalAttr [protected] |
ZIP_SIZE_TYPE CZipFileHeader::m_uLocalComprSize |
WORD CZipFileHeader::m_uLocalFileNameSize [protected] |
ZIP_SIZE_TYPE CZipFileHeader::m_uLocalUncomprSize |
The compression method. It can be one of the CZipCompressor::CompressionMethod values.
Definition at line 503 of file ZipFileHeader.h.
ZIP_SIZE_TYPE CZipFileHeader::m_uOffset |
Relative offset of the local header with respect to CZipFileHeader::m_uVolumeStart.
Definition at line 513 of file ZipFileHeader.h.
ZIP_SIZE_TYPE CZipFileHeader::m_uUncomprSize |
unsigned char CZipFileHeader::m_uVersionMadeBy |
The version of the software that created the archive.
Definition at line 500 of file ZipFileHeader.h.
ZIP_VOLUME_TYPE CZipFileHeader::m_uVolumeStart |
The volume number at which the compressed file starts.
Definition at line 509 of file ZipFileHeader.h.