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

CZipCentralDir Class Reference

#include <ZipCentralDir.h>

List of all members.


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
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
void Init (CZipStorage *pStorage, ZipArchiveLib::CZipCallbackProvider *pCallbacks, CZipStringStoreSettings *pStringSettings, CZipCentralDir *pSource=NULL)
bool IsConsistencyCheckOn (int iLevel)
bool IsFindFastEnabled ()
bool IsValidIndex (ZIP_INDEX_TYPE uIndex) const
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)
bool SetFileComment (ZIP_INDEX_TYPE uIndex, LPCTSTR lpszComment)
void Write ()

Public Attributes

int m_iIgnoredChecks
ZipArchiveLib::CZipCallbackProvider * m_pCallbacks
CZipFileHeaderm_pOpenedFile
 It points to the currently opened file or it is NULL, if no file is opened.
CZipStoragem_pStorage
CZipStringStoreSettingsm_pStringSettings

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 (bool bExhaustiveRead)
void ReadZip64Info ()
bool RemoveDataDescr (bool bFromBuffer)
void RemoveHeaders ()
void ThrowError (int err) const
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

CZipArray< CZipFindFast * > * m_pFindArray
CZipArray< CZipFileHeader * > * m_pHeaders
CInfom_pInfo

Classes

struct  CInfo
struct  CZipFindFast

Detailed Description

Represents the central directory record in the 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:
header Used as a template for the data stored inside the archive.
uReplaceIndex The index of the file to be replaced. Use ZIP_FILE_INDEX_UNSPECIFIED, if the index is not known.
iLevel The compression level.
bRichHeaderTemplateCopy true, if copy crc and sizes values from header; false otherwise.
Returns:
The new header.
Note:
Throws exceptions.

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.
Note:
Throws exceptions.

void CZipCentralDir::CloseNewFile (  ) 

Closes a file opened for reading inside the archive.

Note:
Throws exceptions.

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

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

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.

Note:
Throws exceptions.
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 [inline]

Gets the global comment.

See also:
CZipArchive::GetGlobalComment

ZIP_ARRAY_SIZE_TYPE CZipCentralDir::GetCount (  )  const [inline]

Gets 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]

Gets the Find Fast index.

See also:
CZipArchive::GetFindFastIndex

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

Gets the information about the central directory.

See also:
CZipArchive::GetCentralDirInfo

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

Gets 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

void CZipCentralDir::Init ( CZipStorage pStorage,
ZipArchiveLib::CZipCallbackProvider *  pCallbacks,
CZipStringStoreSettings pStringSettings,
CZipCentralDir pSource = NULL 
)

Initializes the object.

Parameters:
pStorage The current storage to use.
pCallbacks The current callbacks provider.
pStringSettings The current string settings.
pSource If not NULL, then it specifies the central directory for sharing.
Note:
Throws exceptions.

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::IsConsistencyCheckOn ( int  iLevel  )  [inline]

Checks if the specified consistency check should be performed or not.

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

bool CZipCentralDir::IsFindFastEnabled (  )  [inline]

Gets a value indicating whether the Find Fast feature is enabled or not.

Returns:
The value of CInfo::m_bFindFastEnabled.

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.

void CZipCentralDir::LockAccess (  )  [inline, protected]

Locks the access to the shared data.

Note:
Throws exceptions.
See also:
UnlockAccess

CreateSharedData

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.
Note:
Throws exceptions.

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

Gets the information about the file with the given index.

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

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

Gets the information about the file with the given index.

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

void CZipCentralDir::Read ( bool  bExhaustiveRead  ) 

Reads the central directory from the archive.

Parameters:
bExhaustiveRead true, if the exhaustive read should be performed, false otherwise.
Note:
Throws exceptions.
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.
Note:
Throws exceptions.
See also:
CZipArchive::SetExhaustiveRead

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.

Note:
Throws exceptions.

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

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

Parameters:
bFromBuffer If true, removes 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.
Note:
Throws exceptions.

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

Removes the 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 not known.
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.
Note:
Throws exceptions.

void CZipCentralDir::RemoveFromDisk (  ) 

Removes physically the central directory from the archive.

Note:
Throws exceptions.

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 not known.

void CZipCentralDir::SetComment ( LPCTSTR  lpszComment  ) 

Sets the global comment.

See also:
CZipArchive::SetGlobalComment

bool CZipCentralDir::SetFileComment ( ZIP_INDEX_TYPE  uIndex,
LPCTSTR  lpszComment 
)

Sets the file comment.

See also:
CZipArchive::SetFileComment

void CZipCentralDir::ThrowError ( int  err  )  const [protected]

Throws an exception with the given code.

void CZipCentralDir::UnlockAccess (  )  [inline, protected]

Unlocks the access to the shared data.

Note:
Throws exceptions.
See also:
LockAccess

CreateSharedData

void CZipCentralDir::Write (  ) 

Writes the central directory to the archive.

Note:
Throws exceptions.

void CZipCentralDir::WriteCentralEnd (  )  [protected]

Writes the End of Central Directory Record.

Returns:
The size of the record.
Note:
Throws exceptions.

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.

Note:
Throws exceptions.


Member Data Documentation

The End of Central Directory Record signature.

The Zip64 End of Central Directory Record signature.

The Zip64 End of Central Directory Locator signature.

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

See also:
CZipArchive::SetIgnoredConsistencyChecks

ZipArchiveLib::CZipCallbackProvider* CZipCentralDir::m_pCallbacks

Points to the current callback provider.

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 the files inside the archive.

See also:
CZipFileHeader

The central directory information.

See also:
CInfo

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

The current string store settings.

See also:
SetStringStoreSettings


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