OnCorruption
Previous  Top  Next

:OnCorruption - Callback Slot for Detection of Zip File Corruption.

Callback Slot

:OnCorruption := {|Self| ... } --> nStatus  

Parameters

Self   
Self contains a reference to the XbZLibZip object itself.  

Expected Return Value

nStatus  
nStatus is the new value of the Zip File's (Error) Status instance variable :Status, which will be set by the protected :AutoFix() method. Possible values are the following Define Constants from the XbZLib.ch file:  
 
Define
Value
Description
XBZ_FILE_OK
0
All Entries in Zip File are OK.
XBZ_FILE_NO_DIR
1
No Central Directory Found.
XBZ_FILE_NO_ENTRIES
2
No Entries found in Central Directory.
XBZ_FILE_CORRUPT
3
Corrupt Entries found in Zip File.
 

Description

If any kind of Data Corruption is found by the :Open() method -- when XBZ_OPEN_TEST was specified as Open Mode -- the protected :AutoFix() method is automatically called. This method will by default call the :Fix() method, unless the :OnCorruption Callback Slot contains a CodeBlock, which would then be called instead of the :Fix() method. This CodeBlock must return a valid nStatus code (see above for possible values). This CodeBlock may either correct the corruption, or might do nothing but return the new nStatus value. Invalid (or missing) return values will default to the original value of the :Status instance variable, which will be updated accordingly by the :AutoFix() method.  

Examples

·Standard default behavior -- Call default :Fix() method automatically:  

oZip:OnCorruption := NIL  

·Standard default behavior -- Call default :Fix() method automatically:  

oZip:OnCorruption := {|oZ| oZ:Fix()}  

·Ignore Corruptions – Do nothing:  

oZip:OnCorruption := {|oZ| XBZ_FILE_OK}  

·Call a UDF (User-Defined Function) called "MyFix()" which should return an appropriate nStatus Code:  

oZip:OnCorruption := {|oZ| MyFix(oZ)}