Test()
|
Previous Top Next |
:Test([<lExhaustive>]) --> nStatus
|
<lExhaustive>
|
<lExhaustive> optionally determines if the Zip File should be Searched for lost Central Directory and Local File Records, instead of simply using the records in the existing Central Directory (if one exists). This parameter defaults to .F. (FALSE), if any Central Directory entries exist. If no Central Directory entry exists, it will always be set to .T. (TRUE), no matter what value was actually specified.
|
The updated value of the :Status instance variable, which contains the Zip File Status. Possible values are the following Define Constants from the XbZLib.ch file:
|
|
|
This method tests either all the Files that are listed in the Zip File's Central Directory for consistency and valid CRCs, or if no Files are listed or the optional <lExhaustive> parameter was set to .T. (TRUE), searches for orphaned Central Directory entries as well as orphaned Local File entries in the Zip File, and tests those for consistency and valid CRCs.
|
|
After the Test, the program will attempt to automatically fix the Zip File if any corrupted or orphaned records were found. See also the :Fix() method and :OnCorruption Callback variable.
|
|
The process can normally be interrupted by pressing the ESC Key or by creating an xbeP_Close event. Alternatively, if the :CheckEvents Callback is set to a user-defined routine, this behavior can be either modified or disabled. See the :CheckEvents Callback documentation for more details.
|
|
The test routine is smart enough to ignore all Central Directory and Local File Records that might be inside of other Zip Files that were stored inside the opened Zip File. The PkZipFix program on the other hand, will "find" and add such records to the new Zip File that it creates, and might even add corrupt and invalid records to that file.
|
Open a Zip File named "MyArchive.zip" and Test all of the (File) Entries in it. Then show the result:
|
|
LOCAL cZipFile := 'MyArchive.zip'
|
LOCAL oZip := XbZLibZip():New(cZipFile)
|
LOCAL nStatus := XBZ_FILE_OK
|
if oZip:IsOpen()
|
nStatus := oZip:Test()
|
do case
|
case nStatus == XBZ_FILE_OK
|
QOut('Zip File: "' + cZipFile + '" is OK!')
|
case nStatus == XBZ_FILE_NO_DIR
|
QOut('"' + cZipFile + '" has no Central Directory!')
|
case nStatus == XBZ_FILE_NO_ENTRIES
|
QOut('"' + cZipFile + '" contains no Entries!'
|
case nStatus == XBZ_FILE_CORRUPT
|
QOut('"' + cZipFile + '" contains corrupt Entries!)
|
endcase
|
endif
|
oZip:Close()
|