TestEntry()
|
Previous Top Next |
:TestEntry(<cEntry> | <nEntry> | <oEntry>,
|
[<lFakeCDRec>]) --> nStatus
|
The first Parameter can be either a Character String, a Number, or a Central Directory Record Object:
|
|
<cEntry>
|
<cEntry> specifies the File Name of the Central Directory Record Entry that contains the information for the (File) Entry that should be tested in the Zip File.
|
<nEntry>
|
<nEntry> specifies the Index Number of the Central Directory Record Entry that contains the information for the (File) Entry that should be tested in the Zip File.
|
<oEntry>
|
<oEntry> specifies the ZipCentralDirectoryRecord object of the (File) Entry that should be tested in the Zip File.
|
<lFakeCDRec>
|
<lFakeCDRec> optionally specifies if the given Central Directory Record object is a real record -- rather than an artificial test record that was created from an orphaned Local File Record, just for testing. The default value is .F. (FALSE) and a real, existing Central Directory Record object is assumed.
|
This method returns the (new) Status of the tested (File) Entry. This value is a Bit Mask. If no Bit is set, no Error was found, and the returned value will be Zero (0). Otherwise, the appropriate Bit(s) for each of the found Errors is set. The following Define Constants from the XbZLib.ch file are used for Bits 1 through XBZ_MAX_ERROR_CODES, in addition to XBZ_ENTRY_OK, which means that no Error was found:
|
|
|
|
Bits 4 through 12 are set if the corresponding Fields/Values of the Central Directory and Local File Records differ from each other. The Extra Field and Extra Field Length can differ without this being a problem or Error!
|
This method tests the (File) Entry of the given Central Directory Record for existence and consistency with the corresponding Local File Record, including the CRC of the Data.
|
|
If the given Central Directory Record is marked as a test-only record that was created from an orphaned Local File Record, the XBZ_NO_CDREC Error Bit is set. If no corresponding Local File Record can be found, the XBZ_NO_LFDREC Error Bit is set. Otherwise, all Fields of the Local File Record are compared with the corresponding Fields of the given Central Directory Record. In addition, the actual CRC of the Data is compared to the saved CRC of the Local File Record. If any of the Fields or the CRC differs from the saved values, the corresponding Error Bit is set. The resulting Status/Error Code of the (File) Entry is used to update the (File) Entry's Status value, and the resulting value is then returned.
|
Open an existing Zip File named "MyArchive.zip" and test a File Entry named "File2Test.xxx" in it. Then show some of the possible test results and close the Zip File:
|
|
LOCAL oZip := XbZLibZip():New('MyArchive.zip')
|
LOCAL nStatus := oZip:TestEntry('File2Test.xxx')
|
if nStatus == XBZ_ENTRY_OK
|
QOut('Entry "File2Test.xxx" is OK!')
|
elseif nStatus[XBZ_CRC_WRONG]
|
QOut('Error: CRC of Entry "File2Test.xxx" is invalid!')
|
else
|
QOut('Error: Entry "File2Test.xxx" might be corrupt!')
|
endif
|
oZip:Close()
|