CZipActionCallback Struct Reference

#include <ZipCallback.h>

Inheritance diagram for CZipActionCallback:

Inheritance graph
[legend]

List of all members.

Classes

struct  CMultiActionsInfo

Public Types

enum  CallbackType {
  cbNothing = 0x0000, cbAdd = 0x0001, cbAddTmp = 0x0002, cbAddStore = 0x0004,
  cbExtract = 0x0008, cbDeleteCnt = 0x0010, cbDelete = 0x0020, cbTest = 0x0040,
  cbSave = 0x0080, cbGet = 0x0100, cbModify = 0x0200, cbMoveData = 0x0400,
  cbCalculateForMulti = 0x0800, cbMultiAdd = 0x1000 | cbAdd, cbEncryptPrepare = 0x2000, cbEncryptMoveData = 0x4000,
  cbEncrypt = 0x8000, cbMultiEncrypt = 0x10000 | cbEncryptMoveData | cbEncrypt, cbNextValue = 0x20000, cbSubActions = cbAddTmp | cbAddStore | cbDeleteCnt | cbMoveData | cbCalculateForMulti | cbEncryptPrepare | cbEncryptMoveData,
  cbActions = cbAdd | cbExtract | cbDelete | cbTest | cbSave | cbGet | cbModify | cbEncrypt, cbMultiActions = cbMultiAdd | cbMultiEncrypt, cbAll = cbActions | cbSubActions | cbMultiActions
}

Public Member Functions

virtual void CallbackEnd ()
CMultiActionsInfoGetMultiActionsInfo ()
virtual int GetStepSize ()
virtual void Init (LPCTSTR lpszFileInZip=NULL, LPCTSTR lpszExternalFile=NULL)
ZIP_SIZE_TYPE LeftToProcess () const
virtual void MultiActionsEnd ()
virtual void MultiActionsInit (ZIP_SIZE_TYPE uTotalFilesToProcess, ZIP_SIZE_TYPE uTotalBytesToProcess, int iReactType)
virtual bool MultiActionsNext ()
bool RequestCallback (ZIP_SIZE_TYPE uProgress=1)
bool RequestLastCallback (ZIP_SIZE_TYPE uProgress=0)
void SetReactType (int iType)
virtual void SetTotal (ZIP_SIZE_TYPE uTotalToDo)

Public Attributes

int m_iType
CZipString m_szFileInZip
 The name of the file being processed in the archive.
ZIP_SIZE_TYPE m_uProcessed
 The total amount of data processed so far.
ZIP_SIZE_TYPE m_uTotalToProcess

Protected Member Functions

void CacheStepSize ()
virtual bool CallCallback (ZIP_SIZE_TYPE uProgress)
void ResetProgressStage ()

Friends

class CZipArchive
class CZipCentralDir


Detailed Description

When you derive from CZipActionCallback, you can use the new class as a callback object when adding, extracting, deleting, testing files or saving the central directory. You need to override the CZipActionCallback::Callback method. The value of the uProgress parameter in the callback method is the amount of data just processed.

See also:
Progress Notifications: Using Callback Objects

CZipActionCallback::Callback

CZipArchive::SetCallback

Definition at line 152 of file ZipCallback.h.


Member Enumeration Documentation

Values used for specifying a callback type in the CZipArchive::SetCallback method. You can assign several values to the same callback object (use the logical OR).

See also:
Progress Notifications: Using Callback Objects

CZipArchive::SetCallback

CZipActionCallback

Enumerator:
cbNothing  Not used. You can use it for your own purposes.
cbAdd  Compressing a file. The callback called when adding a file with one of the CZipArchive::AddNewFile methods.
cbAddTmp  Moving a file from a temporary archive. The callback called while adding a file (only on a segmented archive) when the smartness level contains CZipArchive::zipsmCheckForEff or CZipArchive::zipsmCheckForEffInMem and if the just compressed file is being moved from a temporary place (file or memory) to the archive.
cbAddStore  Storing a file. The callback called while adding a file and if its compressing has proven to be inefficient and it is now being stored (instead of compressed) in the archive. The smartness level must contain CZipArchive::zipsmCheckForEff or CZipArchive::zipsmCheckForEffInMem. The archive can be segmented or not.
cbExtract  Extracting a file. The callback called when extracting a file with one of the CZipArchive::ExtractFile methods.
cbDeleteCnt  Counting data to process before deleting. The callback called before the actual deletion takes place and the map of holes and continuous areas is being created. It is safe to abort the operation (by returning false from the callback method).
cbDelete  Deleting files. The callback called when moving data while deleting file(s) with the CZipArchive::RemoveFile method or one of the CZipArchive::RemoveFiles methods.
cbTest  Testing a file. The callback called when testing a file with the CZipArchive::TestFile method.
cbSave  Saving the central directory. The callback called when saving the central directory with the CZipCentralDir::Write method (usually on close or flush). It is safe to abort the operation on a segmented archive - the saved part of the central directory will be removed from disk.
cbGet  Getting a file from another archive. The callback called when using one of the CZipArchive::GetFromArchive methods.
cbModify  Renaming a file. The callback called when committing changes with the CZipArchive::CommitChanges method, if there is a need to adjust space for the new filenames.
cbMoveData  Moving data. The callback called when moving data inside the archive. It happens while replacing files to adjust space for the new file or while shifting data with the CZipArchive::ShiftData() method.
cbCalculateForMulti  The callback called when counting files and bytes to process when performing multiple actions. When this callback is called, CZipActionCallback::m_uTotalToProcess is not set (because it is unknown and that's why the counting is performed), but it allows to abort the counting process.
cbMultiAdd  The callback called when adding multiple files with one of the CZipArchive::AddNewFiles methods. This callback also registers for cbAdd.

See also:
Progress Notifications: Using Callback Objects
cbEncryptPrepare  The callback called when preparing existing files for encryption.

See also:
Encryption Methods: How to Best Protect Your Data
cbEncryptMoveData  The callback called in order to report the progress of adjusting space inside the archive before the actual encryption takes place.

See also:
Encryption Methods: How to Best Protect Your Data
cbEncrypt  The callback called for every file being encrypted.

See also:
Encryption Methods: How to Best Protect Your Data
cbMultiEncrypt  The callback called when encrypting existing files in the archive. This callback also registers for cbEncryptMoveData and cbEncrypt.

See also:
Encryption Methods: How to Best Protect Your Data

Progress Notifications: Using Callback Objects

cbNextValue  Reserved. You can declare your own callback types above this value. Do not use the numeric value, but the symbol name - the value may change in the future releases of the library.
cbSubActions  All sub-actions. Represents the sub-actions callbacks - they are called as a part of bigger actions (cbAddTmp | cbAddStore | cbDeleteCnt | cbMoveData | cbCalculateForMulti | cbEncryptPrepare | cbEncryptMoveData).
cbActions  Main callbacks. Represents the main action callbacks (cbAdd | cbExtract | cbDelete | cbTest | cbSave | cbGet | cbModify | cbEncrypt).
cbMultiActions  Multiple action callbacks. Represents the multiple action callbacks.
cbAll  All values. Use this value to use one callback object for all callback types.

Definition at line 167 of file ZipCallback.h.


Member Function Documentation

void CZipActionCallback::CacheStepSize (  )  [inline, protected]

Caches the value returned from the GetStepSize() method. Called in the Init()method.

Definition at line 686 of file ZipCallback.h.

virtual void CZipActionCallback::CallbackEnd (  )  [inline, virtual]

Called after the operation finishes. It is not called in case of an exception, but it is called before throwing CZipException::abortedAction or CZipException::abortedSafely.

Definition at line 502 of file ZipCallback.h.

virtual bool CZipActionCallback::CallCallback ( ZIP_SIZE_TYPE  uProgress  )  [inline, protected, virtual]

Calls the Callback() method internally, increases CZipActionCallback::m_uProcessed and lets the CZipActionCallback increase its values, if needed.

Parameters:
uProgress The amount of data processed.
Returns:
The return value from the Callback() method.

Definition at line 675 of file ZipCallback.h.

CMultiActionsInfo* CZipActionCallback::GetMultiActionsInfo (  )  [inline]

Returns the current CMultiActionsInfo object in multiple actions operation or NULL, if the current operation is not one of CZipActionCallback::cbMultiActions actions.

Returns:
The current CMultiActionsInfo object.
See also:
Progress Notifications: Using Callback Objects

Definition at line 562 of file ZipCallback.h.

virtual int CZipActionCallback::GetStepSize (  )  [inline, virtual]

Specifies how often the Callback() method is called. The Callback() method is called every n-th callback request, where n is the value returned from the GetStepSize() method. Override this method to adjust the frequency of calling the callback.

Returns:
The value that determines the frequency of calling the Callback() method. By default, it returns 256 for cbSave, cbDeleteCnt, cbCalculateForMulti and cbEncryptPrepare and 1 for other callback types.
Note:
This method is called in the Init() method and the returned value is cached for further processing. This means that when you override this method, even with some time-consuming operations, it will not affect the in-action performance.

Do not use a too low value, because it may increase significantly the time needed to process a large number of files.

Definition at line 596 of file ZipCallback.h.

virtual void CZipActionCallback::Init ( LPCTSTR  lpszFileInZip = NULL,
LPCTSTR  lpszExternalFile = NULL 
) [inline, virtual]

Called to initialize the callback object. Sets the filenames and resets m_uTotalToProcess and m_uProcessed variables to 0. m_iType variable is already set to the proper value. Called at the beginning of the operation.

Parameters:
lpszFileInZip The file that is being processed in the archive.
lpszExternalFile The external file being processed. This is set to NULL, if the operation takes place in memory.

Definition at line 451 of file ZipCallback.h.

ZIP_SIZE_TYPE CZipActionCallback::LeftToProcess (  )  const [inline]

Returns the amount of data left to process.

Returns:
The amount of data left to process.

Definition at line 528 of file ZipCallback.h.

virtual void CZipActionCallback::MultiActionsEnd (  )  [inline, virtual]

Called at the end of the multiple actions operation. Releases multiple actions information (CMultiActionsInfo). Override this method, if you want this information to be persisted after operation finishes. In that case, CMultiActionsInfo will be released on destruction.

See also:
Progress Notifications: Using Callback Objects

Definition at line 517 of file ZipCallback.h.

virtual void CZipActionCallback::MultiActionsInit ( ZIP_SIZE_TYPE  uTotalFilesToProcess,
ZIP_SIZE_TYPE  uTotalBytesToProcess,
int  iReactType 
) [inline, virtual]

Called when a multiple actions operation is about to begin. Initializes CMultiActionsInfo object.

Parameters:
uTotalFilesToProcess The number of files to process.
uTotalBytesToProcess The number of bytes to process.
iReactType The type of the callback that will cause increasing of values in CMultiActionsInfo. It can be one of CallbackType values.
See also:
Progress Notifications: Using Callback Objects

GetMultiActionsInfo

Note:
When overriding this method, call the base method from your code.

Definition at line 434 of file ZipCallback.h.

virtual bool CZipActionCallback::MultiActionsNext (  )  [inline, virtual]

Called when a next action begins in multiple actions processing. This method calls Callback method with uProgress parameter set to 0.

Returns:
The value returned from the Callback method.
See also:
Progress Notifications: Using Callback Objects
Note:
When overriding this method, call the base method from your code.

Definition at line 489 of file ZipCallback.h.

bool CZipActionCallback::RequestCallback ( ZIP_SIZE_TYPE  uProgress = 1  )  [inline]

Called by processing classes when data processing progressed.

Parameters:
uProgress The amount of data processed.
Returns:
The value returned from Callback, if the method was called; true otherwise.

Definition at line 616 of file ZipCallback.h.

bool CZipActionCallback::RequestLastCallback ( ZIP_SIZE_TYPE  uProgress = 0  )  [inline]

Called by processing classes when data processing is finished to allow calling the Callback() method for the remaining amount of processed data (for which the Callback() has not been called). This usually happens, when GetStepSize() does not return 1.

Parameters:
uProgress The amount of data processed.
Returns:
The value returned from the Callback method, if the method was called; true otherwise.

Definition at line 652 of file ZipCallback.h.

void CZipActionCallback::ResetProgressStage (  )  [inline, protected]

Initializes the values that depend on the frequency of calling the Callback() method. Called with every call to the Callback() method.

See also:
GetStepSize

Definition at line 700 of file ZipCallback.h.

void CZipActionCallback::SetReactType ( int  iType  )  [inline]

Sets the type of the callback, that will cause the current CMultiActionsInfo object to update its progress.

Parameters:
iType The type of the callback. It can be one of the CallbackType values.

Definition at line 573 of file ZipCallback.h.

virtual void CZipActionCallback::SetTotal ( ZIP_SIZE_TYPE  uTotalToDo  )  [inline, virtual]

Called after calculating the total amount of data to process.

Parameters:
uTotalToDo Total amount of data to process. The method initializes m_uTotalToProcess with this value.

Definition at line 470 of file ZipCallback.h.


Member Data Documentation

The type of the callback. It is set to one of the CallbackType values when an action begins. It's useful, if you have more than one callback assigned to the same callback object.

Definition at line 550 of file ZipCallback.h.

The name of the file being processed in the archive.

Definition at line 544 of file ZipCallback.h.

The total amount of data processed so far.

Definition at line 543 of file ZipCallback.h.

The total amount of data to process. This value is set when the SetTotal method is called.

Depending on the action it is set then to:

Definition at line 542 of file ZipCallback.h.


The documentation for this struct 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.