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

#include <ZipStorage.h>

Public Types

enum  SeekType { seekFromBeginning , seekFromEnd , seekCurrent }
enum  State {
  stateOpened = 0x0001 , stateReadOnly = 0x0002 , stateAutoClose = 0x0004 , stateExisting = 0x0008 ,
  stateSegmented = 0x0010 , stateSplit = stateSegmented | 0x0020 , stateBinarySplit = stateSplit | 0x0040 , stateSpan = stateSegmented | 0x0080
}

Public Member Functions

ZIP_SIZE_TYPE AssureFree (ZIP_SIZE_TYPE uNeeded)
void ChangeVolume ()
void ChangeVolume (ZIP_VOLUME_TYPE uNumber)
void ChangeVolumeDec ()
CZipString Close (bool bWrite, bool bGetLastVolumeName=false)
void FinalizeSegm ()
void Flush ()
void FlushBuffers ()
void FlushFile ()
ZIP_VOLUME_TYPE GetCurrentVolume () const
ZIP_SIZE_TYPE GetOccupiedSpace () const
ZIP_SIZE_TYPE GetPosition () const
CZipSplitNamesHandlerGetSplitNamesHandler ()
const CZipSplitNamesHandlerGetSplitNamesHandler () const
CZipString GetSplitVolumeName (ZIP_VOLUME_TYPE uVolume, bool bLast)
ZipArchiveLib::CBitFlagGetState ()
void Initialize ()
bool IsBinarySplit () const
bool IsClosed (bool bArchive) const
bool IsExisting () const
bool IsExistingSegmented () const
bool IsNewSegmented () const
bool IsReadOnly () const
bool IsRegularSplit () const
bool IsSegmented () const
bool IsSpanned () const
bool IsSplit () const
ZIP_FILE_USIZE LocateSignature (char *szSignature, ZIP_SIZE_TYPE uMaxDepth)
void NextVolume (ZIP_SIZE_TYPE uNeeded)
void Open (CZipAbstractFile &af, int iMode, bool bAutoClose)
void Open (LPCTSTR lpszPathName, int iMode, ZIP_SIZE_TYPE uVolumeSize)
DWORD Read (void *pBuf, DWORD iSize, bool bAtOnce)
ULONGLONG Seek (ULONGLONG lOff, SeekType iSeekType=seekFromBeginning)
void SeekInBinary (ZIP_FILE_SIZE lOff, bool bSeekToBegin=false)
bool SetSplitNamesHandler (CZipSplitNamesHandler *pNames, bool bAutoDelete)
void UpdateSegmMode (ZIP_VOLUME_TYPE uLastVolume)
ZIP_SIZE_TYPE VolumeLeft () const
void Write (const void *pBuf, DWORD iSize, bool bAtOnce)

Public Attributes

CZipAbstractFile * m_pFile

Static Public Attributes

static char m_gszExtHeaderSignat []
static const ZIP_FILE_USIZE SignatureNotFound

Protected Member Functions

void CallCallback (ZIP_SIZE_TYPE uNeeded, int iCode, CZipString szTemp)
CZipString ChangeSpannedRead ()
CZipString ChangeSplitRead ()
void EmptyWriteBuffer ()
DWORD GetFreeInBuffer () const
ZIP_SIZE_TYPE GetFreeVolumeSpace () const
ZIP_SIZE_TYPE GetLastDataOffset ()
bool OpenFile (LPCTSTR lpszName, UINT uFlags, bool bThrow=true)
CZipString RenameLastFileInSplitArchive ()
void WriteInternalBuffer (const char *pBuf, DWORD uSize)

Protected Attributes

int m_iLocateBufferSize
int m_iWriteBufferSize
CZipSegmCallbackm_pSpanChangeVolumeFunc
CZipSegmCallbackm_pSplitChangeVolumeFunc
CZipAutoBuffer m_pWriteBuffer
ZIP_SIZE_TYPE m_uBytesBeforeZip
DWORD m_uBytesInWriteBuffer
ZIP_SIZE_TYPE m_uBytesWritten
ZIP_SIZE_TYPE m_uCurrentVolSize
ZIP_VOLUME_TYPE m_uCurrentVolume
ZIP_SIZE_TYPE m_uSplitData

Friends

class CZipArchive
class CZipCentralDir

Detailed Description

Represents the storage layer for an archive.

Member Enumeration Documentation

◆ SeekType

The direction of the seeking operation.

See also
CZipStorage::Seek
Enumerator
seekFromBeginning 

Start seeking from the beginning of a file.

seekFromEnd 

Start seeking from the end of a file.

seekCurrent 

Start seeking from the current position in the archive. This value can cause a volume change when a segmented archive is opened for reading.

◆ State

Storage state.

Enumerator
stateOpened 

The storage file is opened.

stateReadOnly 

The storage file is opened as read-only.

stateAutoClose 

The storage file will be closed when the storage is closed.

stateExisting 

The storage file existed before opening.

stateSegmented 

The current archive is segmented.

stateSplit 

The current archive is split.

stateBinarySplit 

The current archive is binary split.

stateSpan 

The current archive is spanned.

Member Function Documentation

◆ AssureFree()

ZIP_SIZE_TYPE CZipStorage::AssureFree ( ZIP_SIZE_TYPE uNeeded)

Ensures than in a segmented archive, there is enough free space on the current volume.

Parameters
uNeededThe size of the required free space in bytes.
Returns
The number of free bytes on the current volume.

◆ CallCallback()

void CZipStorage::CallCallback ( ZIP_SIZE_TYPE uNeeded,
int iCode,
CZipString szTemp )
protected

Calls the segmented callback object. Throws an exception if the callback method returns false.

Parameters
uNeededThe minimum number of free bytes required on the disk.
iCodeThe code to be passed to the callback method.
szTempThe string to be used as a filename (as an argument in the CZipException::Throw method) when an exception must be thrown.
See also
CZipArchive::SetSegmCallback

◆ ChangeSpannedRead()

CZipString CZipStorage::ChangeSpannedRead ( )
protected

Changes a disk when processing a spanned archive.

◆ ChangeSplitRead()

CZipString CZipStorage::ChangeSplitRead ( )
protected

Changes a file when processing a split archive.

◆ ChangeVolume() [1/2]

void CZipStorage::ChangeVolume ( )
inline

Changes the current volume to the next volume during extract operations.

◆ ChangeVolume() [2/2]

void CZipStorage::ChangeVolume ( ZIP_VOLUME_TYPE uNumber)

Changes the volume during extract operations.

Parameters
uNumberA zero-based number of the requested volume.

◆ ChangeVolumeDec()

void CZipStorage::ChangeVolumeDec ( )
inline

Changes the current volume to the previous volume during extract operations.

◆ Close()

CZipString CZipStorage::Close ( bool bWrite,
bool bGetLastVolumeName = false )

Closes the storage.

Parameters
bWriteSet to false, if the storage should not perform any write operations.
bGetLastVolumeNameSet to true, if the storage should return the path.
Returns
The file path of the archive or of the last volume in the archive. Only if bGetLastVolumeName is set to true.

◆ EmptyWriteBuffer()

void CZipStorage::EmptyWriteBuffer ( )
inlineprotected

Flushes without writing. It can be used only on not segmented archives.

◆ FinalizeSegm()

void CZipStorage::FinalizeSegm ( )

Closes a segmented archive in creation and reopens it as an existing segmented archive. No modifications are allowed afterwards. The archive may also turn out to be a not segmented archive.

◆ Flush()

void CZipStorage::Flush ( )

Flushes the data from the read buffer to the disk.

◆ FlushBuffers()

void CZipStorage::FlushBuffers ( )
inline

Flushes both internal buffers and file buffers.

◆ FlushFile()

void CZipStorage::FlushFile ( )
inline

Forces any data remaining in the file buffer to be written to the disk.

◆ GetCurrentVolume()

ZIP_VOLUME_TYPE CZipStorage::GetCurrentVolume ( ) const
inline

Returns a zero-based number of the current volume.

◆ GetFreeInBuffer()

DWORD CZipStorage::GetFreeInBuffer ( ) const
inlineprotected

Returns the free space left in the write buffer.

Returns
The free space in bytes.

◆ GetFreeVolumeSpace()

ZIP_SIZE_TYPE CZipStorage::GetFreeVolumeSpace ( ) const
protected

Returns the free space size on the current removable disk.

Returns
The free space in bytes.

◆ GetLastDataOffset()

ZIP_SIZE_TYPE CZipStorage::GetLastDataOffset ( )
inlineprotected

Returns the file offset after the last data byte in the archive.

Returns
The file offset after the last data byte in the archive.

◆ GetOccupiedSpace()

ZIP_SIZE_TYPE CZipStorage::GetOccupiedSpace ( ) const
inline

Returns the total size currently occupied by the archive.

Returns
The length of the current archive file increased by the number of bytes in the write buffer.

◆ GetPosition()

ZIP_SIZE_TYPE CZipStorage::GetPosition ( ) const
inline

Returns the position in the file, taking into account the number of bytes in the write buffer and the number of bytes before the archive.

Returns
The position in the file.
Note
For binary split archives, it returns the position from the beginning of the first part.

◆ GetSplitNamesHandler() [1/2]

CZipSplitNamesHandler * CZipStorage::GetSplitNamesHandler ( )
inline

Returns the current split names handler.

Returns
The current split names handler.
See also
CZipSplitNamesHandler

◆ GetSplitNamesHandler() [2/2]

const CZipSplitNamesHandler * CZipStorage::GetSplitNamesHandler ( ) const
inline

Returns the current split names handler (const).

Returns
The current split names handler.
See also
CZipSplitNamesHandler

◆ GetSplitVolumeName()

CZipString CZipStorage::GetSplitVolumeName ( ZIP_VOLUME_TYPE uVolume,
bool bLast )
inline

Gets the expected path of a volume name in a split archive.

Parameters
uVolumeThe volume's zero-based index.
bLastIf true, the volume is expected to be the last volume; false otherwise.
Returns
The expected path of a volume name in a split archive.

◆ GetState()

ZipArchiveLib::CBitFlag & CZipStorage::GetState ( )
inline

Gets the current state flags of the storage.

Returns
Reference to the state bit flags.

◆ Initialize()

void CZipStorage::Initialize ( )

Initializes the storage object to default state.

◆ IsBinarySplit()

bool CZipStorage::IsBinarySplit ( ) const
inline

Returns the value indicating whether the archive is a binary split archive.

Returns
true, if the archive is a binary split archive; false otherwise.

◆ IsClosed()

bool CZipStorage::IsClosed ( bool bArchive) const
inline

The same as the CZipArchive::IsClosed method.

◆ IsExisting()

bool CZipStorage::IsExisting ( ) const
inline

Returns the value indicating whether the archive is an existing archive.

Returns
true, if the archive is an existing archive; false, if the archive is a new archive.

◆ IsExistingSegmented()

bool CZipStorage::IsExistingSegmented ( ) const
inline

Returns the value indicating whether the archive is an existing segmented archive.

Returns
true, if the archive is an existing segmented archive; false otherwise.

◆ IsNewSegmented()

bool CZipStorage::IsNewSegmented ( ) const
inline

Returns the value indicating whether the archive is a new segmented archive.

Returns
true, if the archive is a new segmented archive; false otherwise.

◆ IsReadOnly()

bool CZipStorage::IsReadOnly ( ) const
inline

The same as the CZipArchive::IsReadOnly method.

◆ IsRegularSplit()

bool CZipStorage::IsRegularSplit ( ) const
inline

Returns the value indicating whether the archive is a regular split archive (not binary).

Returns
true, if the archive is a regular split archive; false otherwise.

◆ IsSegmented()

bool CZipStorage::IsSegmented ( ) const
inline

Returns the value indicating whether the archive is a segmented archive.

Returns
true, if the archive is a segmented archive; false otherwise.

◆ IsSpanned()

bool CZipStorage::IsSpanned ( ) const
inline

Returns the value indicating whether the archive is a spanned archive.

Returns
true, if the archive is a spanned archive; false otherwise.

◆ IsSplit()

bool CZipStorage::IsSplit ( ) const
inline

Returns the value indicating whether the archive is a split archive (binary or regular).

Returns
true, if the archive is a split archive; false otherwise.

◆ LocateSignature()

ZIP_FILE_USIZE CZipStorage::LocateSignature ( char * szSignature,
ZIP_SIZE_TYPE uMaxDepth )

Reverse-finds the location of the given signature starting from the current position in file.

Parameters
szSignatureThe signature to locate.
uMaxDepthThe maximum number of bytes to search for szSignature.
Returns
The location of the signature.

◆ NextVolume()

void CZipStorage::NextVolume ( ZIP_SIZE_TYPE uNeeded)

Changes volumes during writing to a segmented archive.

Parameters
uNeededThe number of bytes needed in the volume.

◆ Open() [1/2]

void CZipStorage::Open ( CZipAbstractFile & af,
int iMode,
bool bAutoClose )

Opens a new or existing archive in memory. The meaning for the parameters is the same as in the CZipArchive::Open(CZipAbstractFile& , int, bool) method.

◆ Open() [2/2]

void CZipStorage::Open ( LPCTSTR lpszPathName,
int iMode,
ZIP_SIZE_TYPE uVolumeSize )

Opens or creates an archive.

The meaning for the parameters is the same as in the CZipArchive::Open(LPCTSTR, int, ZIP_SIZE_TYPE) method.

◆ OpenFile()

bool CZipStorage::OpenFile ( LPCTSTR lpszName,
UINT uFlags,
bool bThrow = true )
protected

Opens a physical file.

Parameters
lpszNameThe name of the file to open.
uFlagsThe file open flags.
bThrowIf true, throw an exception in case of failure.
Returns
true if successful; false otherwise.

◆ Read()

DWORD CZipStorage::Read ( void * pBuf,
DWORD iSize,
bool bAtOnce )

Reads a chunk of data from the archive.

Parameters
pBufThe buffer to receive the data.
iSizeThe number of bytes to read.
bAtOnceIf true, no volume change is allowed during reading. If the requested number of bytes cannot be read from a single volume, an exception is thrown.

◆ RenameLastFileInSplitArchive()

CZipString CZipStorage::RenameLastFileInSplitArchive ( )
protected

Renames the last segment file in a split archive when finalizing the archive.

Returns
The name of the last segment.

◆ Seek()

ULONGLONG CZipStorage::Seek ( ULONGLONG lOff,
SeekType iSeekType = seekFromBeginning )

Performs the seeking operation on the m_pFile.

Parameters
lOffThe new position in the file.
iSeekTypeThe direction of the seek operation. It can be one of the SeekType values.

◆ SeekInBinary()

void CZipStorage::SeekInBinary ( ZIP_FILE_SIZE lOff,
bool bSeekToBegin = false )

Performs the seeking operation in a binary split archive.

Parameters
lOffThe offset to move the file pointer.
bSeekToBeginIf true, the file pointer is moved to the beginning before seeking. If false, the file pointer is moved relatively to the current position.

◆ SetSplitNamesHandler()

bool CZipStorage::SetSplitNamesHandler ( CZipSplitNamesHandler * pNames,
bool bAutoDelete )
inline

◆ UpdateSegmMode()

void CZipStorage::UpdateSegmMode ( ZIP_VOLUME_TYPE uLastVolume)

Called only by CZipCentralDir::Read when opening an existing archive.

Parameters
uLastVolumeThe number of the volume the central directory is on.

◆ VolumeLeft()

ZIP_SIZE_TYPE CZipStorage::VolumeLeft ( ) const

Returns the number of free bytes on the current volume.

Returns
The number of free bytes on the current volume.

◆ Write()

void CZipStorage::Write ( const void * pBuf,
DWORD iSize,
bool bAtOnce )

Writes a chunk of data to the archive.

Parameters
pBufThe buffer with data.
iSizeThe number of bytes to write.
bAtOnceIf true, the whole chunk must fit in the current volume. If there is not enough free space, a volume change is performed.

◆ WriteInternalBuffer()

void CZipStorage::WriteInternalBuffer ( const char * pBuf,
DWORD uSize )
protected

Writes data to the internal buffer.

Parameters
*pBufThe buffer to copy the data from.
uSizeThe number of bytes to write.

Member Data Documentation

◆ m_gszExtHeaderSignat

char CZipStorage::m_gszExtHeaderSignat[]
static

The signature of the extended header.

◆ m_iLocateBufferSize

int CZipStorage::m_iLocateBufferSize
protected

The size of the buffer used in searching for the central directory.

See also
CZipArchive::SetAdvanced

◆ m_iWriteBufferSize

int CZipStorage::m_iWriteBufferSize
protected

The size of the write buffer.

See also
CZipArchive::SetAdvanced

◆ m_pFile

CZipAbstractFile* CZipStorage::m_pFile

Represents the physical storage for the archive (or the current archive segment in segmented archives).

◆ m_pSpanChangeVolumeFunc

CZipSegmCallback* CZipStorage::m_pSpanChangeVolumeFunc
protected

A callback object called when there is a need for a volume change in a spanned archive.

See also
CZipArchive::SetSegmCallback

◆ m_pSplitChangeVolumeFunc

CZipSegmCallback* CZipStorage::m_pSplitChangeVolumeFunc
protected

A callback object called when there is a need for a volume change in a split archive.

See also
CZipArchive::SetSegmCallback

◆ m_pWriteBuffer

CZipAutoBuffer CZipStorage::m_pWriteBuffer
protected

The write buffer caching data.

◆ m_uBytesBeforeZip

ZIP_SIZE_TYPE CZipStorage::m_uBytesBeforeZip
protected

The number of bytes before the actual zip archive in a file.

See also
CZipArchive::GetBytesBeforeZip

◆ m_uBytesInWriteBuffer

DWORD CZipStorage::m_uBytesInWriteBuffer
protected

The number of bytes available in the write buffer.

◆ m_uBytesWritten

ZIP_SIZE_TYPE CZipStorage::m_uBytesWritten
protected

Stores the number of bytes that have been written physically to the current segment. Used only when processing a segmented archive in creation.

◆ m_uCurrentVolSize

ZIP_SIZE_TYPE CZipStorage::m_uCurrentVolSize
protected

The value it holds depends on the segmentation mode:

  • A split archive: the total size of the current volume.
  • A spanned archive: the free space on the current volume.

◆ m_uCurrentVolume

ZIP_VOLUME_TYPE CZipStorage::m_uCurrentVolume
protected

The current volume number in a segmented archive. The value is zero-based.

◆ m_uSplitData

ZIP_SIZE_TYPE CZipStorage::m_uSplitData
protected

The value it holds, depends on the current mode:

  • An opened existing split archive: the number of the last volume ( usually the one with the "zip" extension).
  • A split archive in creation: the size of the volume.

This method is used only when processing split archives.

◆ SignatureNotFound

const ZIP_FILE_USIZE CZipStorage::SignatureNotFound
static

Constant value returned when a signature is not found in the archive.


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