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

#include <ZipCallback.h>

Inheritance diagram for CZipActionCallback:
Inheritance graph

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 (LPCTSTR=NULL)
 
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 Member Functions inherited from CZipCallback
virtual bool Callback (ZIP_SIZE_TYPE uProgress)=0
 

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
 
- Public Attributes inherited from CZipCallback
CZipString m_szExternalFile
 

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

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.

Member Function Documentation

void CZipActionCallback::CacheStepSize ( )
inlineprotected

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

virtual void CZipActionCallback::CallbackEnd ( )
inlinevirtual

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.

virtual bool CZipActionCallback::CallCallback ( ZIP_SIZE_TYPE  uProgress)
inlineprotectedvirtual

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

Parameters
uProgressThe amount of data processed.
Returns
The return value from the Callback() method.
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
virtual int CZipActionCallback::GetStepSize ( )
inlinevirtual

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.
virtual void CZipActionCallback::Init ( LPCTSTR  lpszFileInZip = NULL,
LPCTSTR  lpszExternalFile = NULL 
)
inlinevirtual

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
lpszFileInZipThe file that is being processed in the archive.
lpszExternalFileThe external file being processed. This is set to NULL, if the operation takes place in memory.
ZIP_SIZE_TYPE CZipActionCallback::LeftToProcess ( ) const
inline

Returns the amount of data left to process.

Returns
The amount of data left to process.
virtual void CZipActionCallback::MultiActionsEnd ( )
inlinevirtual

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
virtual void CZipActionCallback::MultiActionsInit ( ZIP_SIZE_TYPE  uTotalFilesToProcess,
ZIP_SIZE_TYPE  uTotalBytesToProcess,
int  iReactType 
)
inlinevirtual

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

Parameters
uTotalFilesToProcessThe number of files to process.
uTotalBytesToProcessThe number of bytes to process.
iReactTypeThe 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.
virtual bool CZipActionCallback::MultiActionsNext ( LPCTSTR  = NULL)
inlinevirtual

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

Parameters
lpszFileInZipThe file that is being processed in the archive.
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.
bool CZipActionCallback::RequestCallback ( ZIP_SIZE_TYPE  uProgress = 1)
inline

Called by processing classes when data processing progressed.

Parameters
uProgressThe amount of data processed.
Returns
The value returned from Callback, if the method was called; true otherwise.
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
uProgressThe amount of data processed.
Returns
The value returned from the Callback method, if the method was called; true otherwise.
void CZipActionCallback::ResetProgressStage ( )
inlineprotected

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

See Also
GetStepSize
void CZipActionCallback::SetReactType ( int  iType)
inline

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

Parameters
iTypeThe type of the callback. It can be one of the CallbackType values.
virtual void CZipActionCallback::SetTotal ( ZIP_SIZE_TYPE  uTotalToDo)
inlinevirtual

Called after calculating the total amount of data to process.

Parameters
uTotalToDoTotal amount of data to process. The method initializes m_uTotalToProcess with this value.

Member Data Documentation

int CZipActionCallback::m_iType

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.

CZipString CZipActionCallback::m_szFileInZip

The name of the file being processed in the archive.

ZIP_SIZE_TYPE CZipActionCallback::m_uProcessed

The total amount of data processed so far.

ZIP_SIZE_TYPE CZipActionCallback::m_uTotalToProcess

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:


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