CZipStorage Class Reference

A low-level class - operates physically on archive (CZipArchive operates logically). More...

#include <ZipStorage.h>

List of all members.

Public Types

enum  ZipSpanMode {
  noSpan, pkzipSpan, tdSpan, suggestedAuto,
  suggestedTd
}
 The type of the disk spanning archive. More...

Public Member Functions

void Open (CZipAbstractFile &af, int iMode)
 Open the archive in memory (new or existing).
void Open (LPCTSTR szPathName, int iMode, int iVolumeSize)
 Open or create an archive.
void FinalizeSpan ()
 Close the disk-spanning archive and reopens as an existing disk-spanning archive or set mode to noSpan.
void UpdateSpanMode (WORD uLastDisk)
 Called only by CZipCentralDir::Read() when opening an existing archive.
DWORD AssureFree (DWORD iNeeded)
 Ensures than in a disk spanning archive, there is enough free space in the current volume.
void Write (const void *pBuf, DWORD iSize, bool bAtOnce)
 Write chunk of data to the archive.
DWORD GetOccupiedSpace () const
bool IsClosed (bool bArchive) const
DWORD Read (void *pBuf, DWORD iSize, bool bAtOnce)
 Read chunk of data from the archive.
DWORD GetPosition () const
 Return the position in the file, taking into account the bytes in the write buffer.
void Flush ()
 Flush the data from the read buffer to the disk.
void FlushFile ()
 Forces any data remaining in the file buffer to be written to the disk.
void NextDisk (int iNeeded, LPCTSTR lpszFileName=NULL)
 A method used to change disks during writing to the disk spanning archive.
int GetCurrentDisk () const
void ChangeDisk (int iNumber)
 Change the disk during extract operations.
int IsSpanMode () const
 Detect the span mode.
bool IsReadOnly ()
 return true if the archive cannot be modified.
void SetTreatAsSingleDisk (bool bSingleDisk=true)
 If you set bSingleDisk to true, no disk change will occur while reading an existing archive.
CZipString Close (bool bAfterException)

Public Attributes

int m_iWriteBufferSize
 The size of the write buffer.
CZipFile m_internalfile
 The physical archive file (on a storage device).
CZipAbstractFile * m_pFile
 The buffer representing the archive.
int m_iSpanMode
 Takes one of the values of ZipSpanMode.
CZipSpanCallbackm_pChangeDiskFunc
 A callback object which method Callback is called when there is a need for a disk change while operating on a pkzipSpan archive.

Static Public Attributes

static char m_gszExtHeaderSignat []
 The signature of the extended header.

Protected Member Functions

void EmptyWriteBuffer ()
 Flush without writing.
bool OpenFile (LPCTSTR lpszName, UINT uFlags, bool bThrow=true)
 Open a physical file.
void ThrowError (int err)
 Throw an exception with the given code.
DWORD VolumeLeft () const
 Return the number of bytes left on the current volume.
CZipString RenameLastFileInTDSpan ()
 Rename last file in TD mode disk spanning archive when done with creating.
void WriteInternalBuffer (const char *pBuf, DWORD uSize)
 Write data to the internal buffer.
DWORD GetFreeVolumeSpace () const
void CallCallback (int iCode, CZipString szTemp)
 Notify the callback object.
CZipString GetTdVolumeName (bool bLast, LPCTSTR lpszZipName=NULL) const
 Construct the name of the volume in tdSpan mode.
CZipString ChangeTdRead ()
 Change the disk in tdSpan mode.
CZipString ChangePkzipRead ()
 Change the disk in pkzipSpan mode.
DWORD GetFreeInBuffer () const

Protected Attributes

int m_iTdSpanData
 Used only in TD span mode .
CZipString m_szSpanExtension
 The extension of the last volume.
DWORD m_uBytesInWriteBuffer
 Number of bytes available in the write buffer.
DWORD m_uCurrentVolSize
 The value it holds depends on the open mode:.
DWORD m_uVolumeFreeInBuffer
 number of bytes left free in the write buffer
CZipAutoBuffer m_pWriteBuffer
 Write buffer caching data.
DWORD m_iBytesWritten
 Used only during disk spanning archive creation.
bool m_bNewSpan
 True, if the current archive is a new disk spanning archive.
int m_iCurrentDisk
 The current disk in a disk spanning archive.
bool m_bInMemory
 It is set to true when an archive is created in memory; false otherwise.
bool m_bReadOnly
 It is set to true if OpenMode::zipOpenReadOnly was specified when opening the archive.
bool m_bTreatAsSingleDisk
 Is is set by SetTreatAsSingleDisk.

Friends

class CZipCentralDir


Detailed Description

A low-level class - operates physically on archive (CZipArchive operates logically).

Definition at line 202 of file ZipStorage.h.


Member Enumeration Documentation

enum CZipStorage::ZipSpanMode
 

The type of the disk spanning archive.

See also:
CZipArchive::GetSpanMode
Enumerator:
noSpan  no disk spanning
pkzipSpan  disk spanning compatible with PKZIP
tdSpan  TD mode disk spanning archive
suggestedAuto  Detect the type automatically.

If the archive is on the removable device assume PKZIP compatible, otherwise TD mode compatible.

suggestedTd  If the disk spanning archive is on the removable device assume it is TD mode compatible.

Definition at line 211 of file ZipStorage.h.


Member Function Documentation

DWORD CZipStorage::AssureFree DWORD  iNeeded  ) 
 

Ensures than in a disk spanning archive, there is enough free space in the current volume.

Parameters:
iNeeded size of the free space in bytes
Returns:
the number of free bytes on the current volume
Note:
Throws exceptions.

void CZipStorage::CallCallback int  iCode,
CZipString  szTemp
[protected]
 

Notify the callback object.

Throw an exception if the callback object's method Callback returns false.

Parameters:
iCode a code to be passed to the callback object
szTemp a string to be used as a filename (the second argument of CZipException::Throw) when the exception must be thrown
Note:
Throws exceptions.
See also:
CZipArchive::SetSpanCallback

CZipException::Throw

void CZipStorage::ChangeDisk int  iNumber  ) 
 

Change the disk during extract operations.

Parameters:
iNumber a zero-based disk number requested
Returns:

CZipString CZipStorage::Close bool  bAfterException  ) 
 

Parameters:
bAfterException set to true after the library has throw an exception. The simplified mode is used then. In this case it'll be possible to reuse the object to operate on another archive, but the current archive file will not be valid anyway.
Returns:
the filepath of the archive (used by CZipArchive::Close)
Note:
Throws exceptions.

void CZipStorage::EmptyWriteBuffer  )  [inline, protected]
 

Flush without writing.

Can be used only on non-disk spanning archives.

Definition at line 460 of file ZipStorage.h.

void CZipStorage::Flush  ) 
 

Flush the data from the read buffer to the disk.

Note:
Throws exceptions.

Referenced by CZipCentralDir::RemoveLastFile().

int CZipStorage::GetCurrentDisk  )  const [inline]
 

Returns:
a zero-based number of the current disk

Definition at line 360 of file ZipStorage.h.

DWORD CZipStorage::GetFreeInBuffer  )  const [inline, protected]
 

Returns:
the count bytes left free in the write buffer

Definition at line 564 of file ZipStorage.h.

DWORD CZipStorage::GetFreeVolumeSpace  )  const [protected]
 

Returns:
the number of free bytes on the current removable disk

DWORD CZipStorage::GetOccupiedSpace  )  const [inline]
 

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

Definition at line 298 of file ZipStorage.h.

DWORD CZipStorage::GetPosition  )  const [inline]
 

Return the position in the file, taking into account the bytes in the write buffer.

Note:
Throws exceptions.

Definition at line 327 of file ZipStorage.h.

CZipString CZipStorage::GetTdVolumeName bool  bLast,
LPCTSTR  lpszZipName = NULL
const [protected]
 

Construct the name of the volume in tdSpan mode.

Parameters:
bLast must be true if constructing the last volume name (an extension "zip" is given)
lpszZipName the name of the archive
Returns:
the new volume name

bool CZipStorage::IsClosed bool  bArchive  )  const [inline]
 

See also:
CZipArchive::IsClosed

Definition at line 306 of file ZipStorage.h.

int CZipStorage::IsSpanMode  )  const [inline]
 

Detect the span mode.

Returns:
  • -1 - existing disk spanning archive opened
  • 0 - no disk spanning archive
  • 1 - disk spanning archive in creation

Definition at line 379 of file ZipStorage.h.

void CZipStorage::NextDisk int  iNeeded,
LPCTSTR  lpszFileName = NULL
 

A method used to change disks during writing to the disk spanning archive.

Parameters:
iNeeded no of bytes needed on the disk
lpszFileName the archive filename
Note:
Throws exceptions.

void CZipStorage::Open LPCTSTR  szPathName,
int  iMode,
int  iVolumeSize
 

Open or create an archive.

The parameters are the same as CZipArchive::Open(LPCTSTR, int, int).

Parameters:
szPathName 
iMode 
iVolumeSize 
Note:
Throws exceptions.
See also:
CZipArchive::Open(LPCTSTR, int, int)

void CZipStorage::Open CZipAbstractFile &  af,
int  iMode
 

Open the archive in memory (new or existing).

The parameters are the same as CZipArchive::Open(CZipAbstractFile& , int).

Parameters:
af 
iMode 
Note:
Throws exceptions.
See also:
CZipArchive::Open(CZipAbstractFile& , int);

bool CZipStorage::OpenFile LPCTSTR  lpszName,
UINT  uFlags,
bool  bThrow = true
[protected]
 

Open a physical file.

Parameters:
lpszName the name of the file to open
uFlags file open flags
bThrow if true then throw an exception in case of failure
Returns:
true if successful

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

Read chunk of data from the archive.

Parameters:
pBuf buffer to receive data
iSize bytes to read
bAtOnce if true, the specified number of bytes must be read from the same volume (no disk change allowed)
Note:
Throws exceptions.

void CZipStorage::SetTreatAsSingleDisk bool  bSingleDisk = true  )  [inline]
 

If you set bSingleDisk to true, no disk change will occur while reading an existing archive.

The purpose of this method is to allow reading archives that have improperly set disk numbers.

Definition at line 396 of file ZipStorage.h.

void CZipStorage::ThrowError int  err  )  [protected]
 

Throw an exception with the given code.

Parameters:
err 
See also:
CZipException::Throw

void CZipStorage::UpdateSpanMode WORD  uLastDisk  ) 
 

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

Parameters:
uLastDisk the disk number the central directory is on
Note:
Throws exceptions.

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

Write chunk of data to the archive.

Parameters:
pBuf buffer with data
iSize bytes to write
bAtOnce if true, the whole data must fit in the current volume, otherwise the disk change is performed
Note:
Throws exceptions.

void CZipStorage::WriteInternalBuffer const char *  pBuf,
DWORD  uSize
[protected]
 

Write data to the internal buffer.

Parameters:
*pBuf the buffer to copy data from
uSize bytes to write
Note:
Throws exceptions.


Member Data Documentation

DWORD CZipStorage::m_iBytesWritten [protected]
 

Used only during disk spanning archive creation.

Tells how many bytes have been written physically to the current volume.

Definition at line 595 of file ZipStorage.h.

int CZipStorage::m_iCurrentDisk [protected]
 

The current disk in a disk spanning archive.

Disk no 0 is the first disk.

Definition at line 606 of file ZipStorage.h.

CZipFile CZipStorage::m_internalfile
 

The physical archive file (on a storage device).

Not used when opening archive in memory with Open(CZipMemFile& , int).

Definition at line 426 of file ZipStorage.h.

int CZipStorage::m_iTdSpanData [protected]
 

Used only in TD span mode .

The value it holds depends on the open mode.

  • Opened existing disk spanning archive - store the number of the last disk ( the one with "zip" extension).
  • Disk spanning archive in creation - the size of the volume.

See also:
CZipArchive::Open

CZipArchive::GetSpanMode

Definition at line 554 of file ZipStorage.h.

int CZipStorage::m_iWriteBufferSize
 

The size of the write buffer.

Set before opening the archive. It is usually set with CZipArchive::SetAdvanced (specify this value as the first argument).

See also:
CZipArchive::SetAdvanced

Definition at line 418 of file ZipStorage.h.

CZipSpanCallback* CZipStorage::m_pChangeDiskFunc
 

A callback object which method Callback is called when there is a need for a disk change while operating on a pkzipSpan archive.

See also:
CZipArchive::SetSpanCallback

Definition at line 449 of file ZipStorage.h.

CZipAbstractFile* CZipStorage::m_pFile
 

The buffer representing the archive.

It is a physical file or a memory buffer depending on what method was used to open the archive. In the first case it is a pointer to m_internalfile.

See also:
Open(LPCTSTR, int, int);

Open(CZipMemFile& mf, int)

Definition at line 437 of file ZipStorage.h.

Referenced by CZipCentralDir::RemoveLastFile().

DWORD CZipStorage::m_uCurrentVolSize [protected]
 

The value it holds depends on the open mode:.

  • tdSpan : the total size of the current volume
  • pkzipSpan: a free space on the current volume

Definition at line 577 of file ZipStorage.h.


The documentation for this class was generated from the following file:
ZipArchive Copyright © 2000 - 2006 Tadeusz Dracz . Generated at Fri Apr 7 13:55:25 2006.