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

#include <ZipCentralDir.h>

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_INDEX_TYPE GetLastIndexAdded () 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, bool bInCentralOnly)
 
void OpenFile (ZIP_INDEX_TYPE uIndex)
 
CZipFileHeaderoperator[] (ZIP_INDEX_TYPE uIndex)
 
const CZipFileHeaderoperator[] (ZIP_INDEX_TYPE uIndex) const
 
void Read ()
 
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.
 
ZipArchiveLib::CBitFlag m_specialFlags
 

Static Public Attributes

static char m_gszSignature []
 The End of Central Directory Record signature.
 
static char m_gszSignature64 []
 The Zip64 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 LockAccess ()
 
void ReadHeaders ()
 
void ReadZip64Info ()
 
bool RemoveDataDescr (bool bFromBuffer)
 
ZIP_INDEX_TYPE RemoveFindFastElement (CZipFileHeader *pHeader, bool bShift)
 
void RemoveHeaders ()
 
void UnlockAccess ()
 
void WriteCentralEnd ()
 
void WriteCentralEnd64 ()
 
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.

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
headerUsed as a template for the data stored inside the archive.
uReplaceIndexThe index of the file to be replaced or ZIP_FILE_INDEX_UNSPECIFIED, if the index is unknown.
iLevelThe compression level.
bRichHeaderTemplateCopytrue, 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
skipCheckingDataDescriptorIf 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
inlineprotected

The method used in comparison involving the Find Fast feature.

Parameters
lpszFileNameThe name of the file.
uIndexThe 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
static int CZipCentralDir::CompareHeaders ( const void *  pArg1,
const void *  pArg2 
)
inlinestaticprotected

The method used in comparison when sorting headers.

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
lpszFileNameThe 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.
ZIP_INDEX_TYPE CZipCentralDir::GetFindFastIndex ( ZIP_INDEX_TYPE  uFindFastIndex) const
inline

Returns the Find Fast index.

See Also
CZipArchive::GetFindFastIndex
void CZipCentralDir::GetInfo ( CInfo info) const
inline

Returns the information about the central directory.

See Also
CZipArchive::GetCentralDirInfo
ZIP_INDEX_TYPE CZipCentralDir::GetLastIndexAdded ( ) const
inline

Returns the index of the recently added file (if any).

Returns
The index of the recently added file or ZIP_FILE_INDEX_UNSPECIFIED if the index is unknown.
ZIP_SIZE_TYPE CZipCentralDir::GetSize ( bool  bWhole = false) const

Returns the central directory size.

Parameters
bWholeIf 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.
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
void CZipCentralDir::Init ( CZipCentralDir pSource = NULL)

Initializes the object.

Parameters
pSourceIf not NULL, it specifies the central directory for sharing.
void CZipCentralDir::InitOnCreate ( CZipArchive pArchive)

Initializes the central directory during construction.

Parameters
pArchiveThe 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
pHeaderThe element to insert.
uIndexThe 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
iLevelThe 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
bool CZipCentralDir::IsFindFastEnabled ( )
inline

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

Returns
The value of CInfo::m_bFindFastEnabled.
bool CZipCentralDir::IsValidIndex ( ZIP_INDEX_TYPE  uIndex) const

Tests if the given file index is valid.

Parameters
uIndexA zero-based index to test.
Returns
true, if the file with the given index exists inside the archive; false otherwise.
void CZipCentralDir::LockAccess ( )
inlineprotected

Locks the access to the shared data.

See Also
UnlockAccess
CreateSharedData
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,
bool  bInCentralOnly 
)

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
uIndexA zero-based index of the file to open.
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)
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
void CZipCentralDir::Read ( )

Reads the central directory from the archive.

void CZipCentralDir::ReadHeaders ( )
protected

Reads file headers from the archive.

void CZipCentralDir::ReadZip64Info ( )
protected

Reads the Zip64 central directory information.

void CZipCentralDir::RebuildFindFastArray ( )
inline

Rebuilds the CZipCentralDir::m_pFindArray array.

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
bFromBufferIf 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
pHeaderThe header to remove.
uIndexThe index of the header to remove. Use ZIP_FILE_INDEX_UNSPECIFIED, if the index is unknown.
bShiftIf 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
pHeaderThe element associated with this object will be removed.
bShiftIf 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
pHeaderThe header to remove.
uIndexThe 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
void CZipCentralDir::ThrowError ( int  err) const

Throws an exception with the given code.

void CZipCentralDir::UnlockAccess ( )
inlineprotected

Unlocks the access to the shared data.

See Also
LockAccess
CreateSharedData
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::WriteCentralEnd64 ( )
protected

Writes the Zip64 End of Central Directory Record.

void CZipCentralDir::WriteHeaders ( bool  bOneDisk)
protected

Writes the file headers to the archive.

Member Data Documentation

char CZipCentralDir::m_gszSignature[]
static

The End of Central Directory Record signature.

char CZipCentralDir::m_gszSignature64[]
static

The Zip64 End of Central Directory Record signature.

char CZipCentralDir::m_gszSignature64Locator[]
static

The Zip64 End of Central Directory Locator signature.

int CZipCentralDir::m_iIgnoredChecks

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

See Also
CZipArchive::SetIgnoredConsistencyChecks
int CZipCentralDir::m_iUnicodeMode
protected

The current Unicode mode.

CZipArchive* CZipCentralDir::m_pArchive
protected

The reference to the main CZipArchive object.

CZipArray<CZipFindFast*>* CZipCentralDir::m_pFindArray
protected

The Find Fast array.

See Also
CZipFindFast
CInfo::m_bFindFastEnabled
CZipArchive::FindFile
CZipArray<CZipFileHeader*>* CZipCentralDir::m_pHeaders
protected

Holds the information about all files inside the archive.

See Also
CZipFileHeader
CInfo* CZipCentralDir::m_pInfo
protected

The central directory information.

See Also
CInfo
CZipFileHeader* CZipCentralDir::m_pOpenedFile

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

CZipStorage* CZipCentralDir::m_pStorage
protected
ZipArchiveLib::CBitFlag CZipCentralDir::m_specialFlags

The currently set special flags.

See Also
CZipArchive::SetSpecialFlags

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