CZipCentralDir Class Reference

#include <ZipCentralDir.h>

List of all members.

Classes

struct  CInfo
struct  CZipFindFast

Public Member Functions

CZipFileHeaderAddNewFile (const CZipFileHeader &header, ZIP_INDEX_TYPE uReplaceIndex, int iLevel, bool bRichHeaderTemplateCopy=false)
void Close ()
void CloseFile (bool skipCheckingDataDescriptor=false)
void CloseNewFile ()
void EnableFindFast (bool bEnable, bool bCaseSensitive)
ZIP_INDEX_TYPE FindFile (LPCTSTR lpszFileName, bool bCaseSensitive, bool bSporadically, bool bFileNameOnly)
ZIP_INDEX_TYPE FindFileNameIndex (LPCTSTR lpszFileName) const
CZipArchiveGetArchive ()
void GetComment (CZipString &szComment) const
ZIP_ARRAY_SIZE_TYPE GetCount () const
ZIP_INDEX_TYPE GetFindFastIndex (ZIP_INDEX_TYPE uFindFastIndex) const
void GetInfo (CInfo &info) const
ZIP_SIZE_TYPE GetSize (bool bWhole=false) const
CZipStorageGetStorage ()
const CZipStringStoreSettingsGetStringStoreSettings () const
int GetUnicodeMode () const
void Init (CZipCentralDir *pSource=NULL)
void InitOnCreate (CZipArchive *pArchive)
bool IsAnyFileModified () const
bool IsConsistencyCheckOn (int iLevel)
bool IsFindFastEnabled ()
bool IsValidIndex (ZIP_INDEX_TYPE uIndex) const
ZIP_FILE_USIZE LocateSignature ()
bool OnFileCentralChange ()
bool OnFileNameChange (CZipFileHeader *pHeader)
void OpenFile (ZIP_INDEX_TYPE uIndex)
const CZipFileHeaderoperator[] (ZIP_INDEX_TYPE uIndex) const
CZipFileHeaderoperator[] (ZIP_INDEX_TYPE uIndex)
void Read (bool bExhaustiveRead)
void RebuildFindFastArray ()
void RemoveAll ()
void RemoveFile (CZipFileHeader *pHeader, ZIP_INDEX_TYPE uIndex=ZIP_FILE_INDEX_UNSPECIFIED, bool bShift=true)
void RemoveFromDisk ()
void RemoveLastFile (CZipFileHeader *pHeader=NULL, ZIP_INDEX_TYPE uIndex=ZIP_FILE_INDEX_UNSPECIFIED)
void SetComment (LPCTSTR lpszComment, UINT codePage)
void SetUnicodeMode (int iMode)
void ThrowError (int err) const
void Write ()

Public Attributes

int m_iIgnoredChecks
CZipFileHeaderm_pOpenedFile
 It points to the currently opened file or it is NULL, if no file is opened.

Static Public Attributes

static char m_gszSignature []
 The End of Central Directory Record signature.
static char m_gszSignature64Locator []
 The Zip64 End of Central Directory Locator signature.

Protected Member Functions

void BuildFindFastArray (bool bCaseSensitive)
void ClearFindFastArray ()
int CompareElement (LPCTSTR lpszFileName, ZIP_INDEX_TYPE uIndex) const
void CreateSharedData ()
void DestroySharedData ()
ZIP_INDEX_TYPE InsertFindFastElement (CZipFileHeader *pHeader, ZIP_INDEX_TYPE uIndex)
void ReadHeaders (bool bExhaustiveRead)
bool RemoveDataDescr (bool bFromBuffer)
ZIP_INDEX_TYPE RemoveFindFastElement (CZipFileHeader *pHeader, bool bShift)
void RemoveHeaders ()
void WriteCentralEnd ()
void WriteHeaders (bool bOneDisk)

Static Protected Member Functions

static int CompareFindFastCollate (const void *pArg1, const void *pArg2)
static int CompareFindFastCollateNoCase (const void *pArg1, const void *pArg2)
static int CompareHeaders (const void *pArg1, const void *pArg2)

Protected Attributes

int m_iUnicodeMode
CZipArchivem_pArchive
CZipArray< CZipFindFast * > * m_pFindArray
CZipArray< CZipFileHeader * > * m_pHeaders
CInfom_pInfo
CZipStoragem_pStorage


Detailed Description

Represents the central directory record in an archive.

Definition at line 48 of file ZipCentralDir.h.


Member Function Documentation

CZipFileHeader* CZipCentralDir::AddNewFile ( const CZipFileHeader header,
ZIP_INDEX_TYPE  uReplaceIndex,
int  iLevel,
bool  bRichHeaderTemplateCopy = false 
)

Adds a new file to the central directory.

Parameters:
header Used as a template for the data stored inside the archive.
uReplaceIndex The index of the file to be replaced or ZIP_FILE_INDEX_UNSPECIFIED, if the index is unknown.
iLevel The compression level.
bRichHeaderTemplateCopy true, if copy crc and sizes values from header; false otherwise.
Returns:
The new header.

void CZipCentralDir::BuildFindFastArray ( bool  bCaseSensitive  )  [protected]

Builds the CZipCentralDir::m_pFindArray array.

void CZipCentralDir::Close (  ) 

Closes the central directory.

void CZipCentralDir::CloseFile ( bool  skipCheckingDataDescriptor = false  ) 

Closes a file opened for reading inside the archive.

Parameters:
skipCheckingDataDescriptor If true, the data descriptor that is located after the compressed data in the archive is checked for validity. Set this value to false after closing the file after an exception was thrown.

void CZipCentralDir::CloseNewFile (  ) 

Closes a file opened for reading inside the archive.

int CZipCentralDir::CompareElement ( LPCTSTR  lpszFileName,
ZIP_INDEX_TYPE  uIndex 
) const [inline, protected]

The method used in comparison involving the Find Fast feature.

Parameters:
lpszFileName The name of the file.
uIndex The index from the CZipCentralDir::m_pFindArray array.
Returns:
The return value has the following meaning:
  • 0 if the filenames are the same
  • < 0 if the filename stored in the array is less than lpszFileName
  • > 0 if the filename stored in the array is greater than lpszFileName

Definition at line 699 of file ZipCentralDir.h.

static int CZipCentralDir::CompareHeaders ( const void *  pArg1,
const void *  pArg2 
) [inline, static, protected]

The method used in comparison when sorting headers.

Definition at line 605 of file ZipCentralDir.h.

void CZipCentralDir::CreateSharedData (  )  [protected]

Creates data that can be shared between different archive objects.

See also:
DestroySharedData

void CZipCentralDir::DestroySharedData (  )  [protected]

Destroys data shared between different archive objects, if the usage reference count of the data is zero.

See also:
CreateSharedData

void CZipCentralDir::EnableFindFast ( bool  bEnable,
bool  bCaseSensitive 
)

Enables Find Fast.

See also:
CZipArchive::EnableFindFast

ZIP_INDEX_TYPE CZipCentralDir::FindFile ( LPCTSTR  lpszFileName,
bool  bCaseSensitive,
bool  bSporadically,
bool  bFileNameOnly 
)

Searches for the file.

See also:
CZipArchive::FindFile

ZIP_INDEX_TYPE CZipCentralDir::FindFileNameIndex ( LPCTSTR  lpszFileName  )  const

Finds the index of the file with the given name.

Parameters:
lpszFileName The name of the file to find.
Returns:
The index in CZipCentralDir::m_pFindArray with the corresponding CZipFindFast structure or ZIP_FILE_INDEX_NOT_FOUND, if there is no such file with the given name.
See also:
CZipArchive::FindFile

void CZipCentralDir::GetComment ( CZipString &  szComment  )  const

Returns the global comment.

See also:
CZipArchive::GetGlobalComment

ZIP_ARRAY_SIZE_TYPE CZipCentralDir::GetCount (  )  const [inline]

Returns the number of files in the archive.

Returns:
The number of files in the archive.

Definition at line 418 of file ZipCentralDir.h.

ZIP_INDEX_TYPE CZipCentralDir::GetFindFastIndex ( ZIP_INDEX_TYPE  uFindFastIndex  )  const [inline]

Returns the Find Fast index.

See also:
CZipArchive::GetFindFastIndex

Definition at line 380 of file ZipCentralDir.h.

void CZipCentralDir::GetInfo ( CInfo info  )  const [inline]

Returns the information about the central directory.

See also:
CZipArchive::GetCentralDirInfo

Definition at line 462 of file ZipCentralDir.h.

ZIP_SIZE_TYPE CZipCentralDir::GetSize ( bool  bWhole = false  )  const

Returns the central directory size.

Parameters:
bWhole If true, include the size of the file headers. If false, the size of the file headers is not included.
Returns:
The size of the central directory.
See also:
CZipArchive::GetCentralDirSize

CZipStorage* CZipCentralDir::GetStorage (  )  [inline]

Returns the current storage.

Returns:
The current storage.

Definition at line 513 of file ZipCentralDir.h.

const CZipStringStoreSettings& CZipCentralDir::GetStringStoreSettings (  )  const

Returns the current string store settings.

See also:
CZipArchive::GetStringStoreSettings

int CZipCentralDir::GetUnicodeMode (  )  const [inline]

Returns the current Unicode mode.

See also:
CZipArchive::GetUnicodeMode

Definition at line 555 of file ZipCentralDir.h.

void CZipCentralDir::Init ( CZipCentralDir pSource = NULL  ) 

Initializes the object.

Parameters:
pSource If not NULL, it specifies the central directory for sharing.

void CZipCentralDir::InitOnCreate ( CZipArchive pArchive  ) 

Initializes the central directory during construction.

Parameters:
pArchive The archive that creates the object.

ZIP_INDEX_TYPE CZipCentralDir::InsertFindFastElement ( CZipFileHeader pHeader,
ZIP_INDEX_TYPE  uIndex 
) [protected]

Inserts a new CZipFindFast element to the CZipCentralDir::m_pFindArray array. Initializes the CZipFindFast object with pHeader and uIndex values.

Parameters:
pHeader The element to insert.
uIndex The original index of pHeader in the central directory. If set to ZIP_FILE_INDEX_UNSPECIFIED, it is assumed to be the last element.
Returns:
The index in the CZipCentralDir::m_pFindArray array.

bool CZipCentralDir::IsAnyFileModified (  )  const

Examines whether any file is modified.

Returns:
true, if there are modified files; false otherwise.
See also:
CZipArchive::IsModified

bool CZipCentralDir::IsConsistencyCheckOn ( int  iLevel  )  [inline]

Returns the value indicating whether the specified consistency check should be performed.

Parameters:
iLevel The level to check. It can be one or more of the CZipArchive::ConsistencyCheck values.
Returns:
true, if the specified check should be performed; false otherwise.
See also:
m_iIgnoredChecks

Definition at line 501 of file ZipCentralDir.h.

bool CZipCentralDir::IsFindFastEnabled (  )  [inline]

Returns the value indicating whether the Find Fast feature is enabled.

Returns:
The value of CInfo::m_bFindFastEnabled.

Definition at line 470 of file ZipCentralDir.h.

bool CZipCentralDir::IsValidIndex ( ZIP_INDEX_TYPE  uIndex  )  const

Tests if the given file index is valid.

Parameters:
uIndex A zero-based index to test.
Returns:
true, if the file with the given index exists inside the archive; false otherwise.

bool CZipCentralDir::OnFileCentralChange (  ) 

Called when data of a file changes in a central directory file header.

Returns:
true, if the change is permitted; false otherwise.

bool CZipCentralDir::OnFileNameChange ( CZipFileHeader pHeader  ) 

Called when a filename of a file in the archive changes.

Returns:
true, if the change is permitted; false otherwise.

void CZipCentralDir::OpenFile ( ZIP_INDEX_TYPE  uIndex  ) 

Opens the file with the given index.

Parameters:
uIndex A zero-based index of the file to open.

const CZipFileHeader* CZipCentralDir::operator[] ( ZIP_INDEX_TYPE  uIndex  )  const [inline]

Returns the information about the file with the given index.

See also:
CZipArchive::operator[](ZIP_INDEX_TYPE) const

Definition at line 406 of file ZipCentralDir.h.

CZipFileHeader* CZipCentralDir::operator[] ( ZIP_INDEX_TYPE  uIndex  )  [inline]

Returns the information about the file with the given index.

See also:
CZipArchive::operator[](ZIP_INDEX_TYPE)

Definition at line 395 of file ZipCentralDir.h.

void CZipCentralDir::Read ( bool  bExhaustiveRead  ) 

Reads the central directory from the archive.

Parameters:
bExhaustiveRead true, if the exhaustive read should be performed, false otherwise.
See also:
CZipArchive::SetExhaustiveRead

void CZipCentralDir::ReadHeaders ( bool  bExhaustiveRead  )  [protected]

Reads file headers from the archive.

Parameters:
bExhaustiveRead true, if the exhaustive read should be performed, false otherwise.
See also:
CZipArchive::SetExhaustiveRead

void CZipCentralDir::RebuildFindFastArray (  )  [inline]

Rebuilds the CZipCentralDir::m_pFindArray array.

Definition at line 475 of file ZipCentralDir.h.

void CZipCentralDir::RemoveAll (  ) 

Removes all files.

bool CZipCentralDir::RemoveDataDescr ( bool  bFromBuffer  )  [protected]

Removes data descriptors from a segmented archive that turned out to be single-segment only. It is not called for encrypted files.

Parameters:
bFromBuffer If true, removes the descriptors from the write buffer in memory otherwise from the file on the disk.
Returns:
false, if the file mapping to memory was not successful (can happen only when bFromBuffer is false); true otherwise.

void CZipCentralDir::RemoveFile ( CZipFileHeader pHeader,
ZIP_INDEX_TYPE  uIndex = ZIP_FILE_INDEX_UNSPECIFIED,
bool  bShift = true 
)

Removes a file header from the central directory.

Parameters:
pHeader The header to remove.
uIndex The index of the header to remove. Use ZIP_FILE_INDEX_UNSPECIFIED, if the index is unknown.
bShift If true, the data inside the archive is moved over the hole created after removing the file. If false, the unused area inside the archive remains.

ZIP_INDEX_TYPE CZipCentralDir::RemoveFindFastElement ( CZipFileHeader pHeader,
bool  bShift 
) [protected]

Removes a CZipFindFast element from the CZipCentralDir::m_pFindArray array.

Parameters:
pHeader The element associated with this object will be removed.
bShift If true, the affected indexes will be shifted; false otherwise.

void CZipCentralDir::RemoveFromDisk (  ) 

Removes physically the central directory from the archive.

void CZipCentralDir::RemoveHeaders (  )  [protected]

Frees the memory allocated for the CZipFileHeader structures.

void CZipCentralDir::RemoveLastFile ( CZipFileHeader pHeader = NULL,
ZIP_INDEX_TYPE  uIndex = ZIP_FILE_INDEX_UNSPECIFIED 
)

Removes last file from the central directory.

Parameters:
pHeader The header to remove.
uIndex The index of the header to remove. Use ZIP_FILE_INDEX_UNSPECIFIED, if the index is unknown.

void CZipCentralDir::SetComment ( LPCTSTR  lpszComment,
UINT  codePage 
)

Sets the global comment.

See also:
CZipArchive::SetGlobalComment

void CZipCentralDir::SetUnicodeMode ( int  iMode  )  [inline]

Sets the current Unicode mode.

See also:
CZipArchive::SetUnicodeMode

Definition at line 547 of file ZipCentralDir.h.

void CZipCentralDir::ThrowError ( int  err  )  const

Throws an exception with the given code.

void CZipCentralDir::Write (  ) 

Writes the central directory to the archive.

void CZipCentralDir::WriteCentralEnd (  )  [protected]

Writes the End of Central Directory Record.

Returns:
The size of the record.

void CZipCentralDir::WriteHeaders ( bool  bOneDisk  )  [protected]

Writes the file headers to the archive.


Member Data Documentation

The End of Central Directory Record signature.

Definition at line 200 of file ZipCentralDir.h.

The Zip64 End of Central Directory Locator signature.

Definition at line 201 of file ZipCentralDir.h.

Consistency checks to ignore. It can be one or more of the CZipArchive::ConsistencyCheck values.

See also:
CZipArchive::SetIgnoredConsistencyChecks

Definition at line 487 of file ZipCentralDir.h.

The current Unicode mode.

Definition at line 600 of file ZipCentralDir.h.

The reference to the main CZipArchive object.

Definition at line 584 of file ZipCentralDir.h.

CZipArray<CZipFindFast*>* CZipCentralDir::m_pFindArray [protected]

The Find Fast array.

See also:
CZipFindFast

CInfo::m_bFindFastEnabled

CZipArchive::FindFile

Definition at line 681 of file ZipCentralDir.h.

CZipArray<CZipFileHeader*>* CZipCentralDir::m_pHeaders [protected]

Holds the information about all files inside the archive.

See also:
CZipFileHeader

Definition at line 655 of file ZipCentralDir.h.

The central directory information.

See also:
CInfo

Definition at line 737 of file ZipCentralDir.h.

It points to the currently opened file or it is NULL, if no file is opened.

Definition at line 202 of file ZipCentralDir.h.

Points to CZipArchive::m_storage.

Definition at line 589 of file ZipCentralDir.h.


The documentation for this class was generated from the following file:

The ZipArchive Library Copyright © 2000 - 2009 Artpol Software - Tadeusz Dracz. Generated at Fri Apr 24 16:46:34 2009.