FixEntry()
|
Previous Top Next |
:FixEntry(<cEntry> | <nEntry> | <oEntry>) --> nStatus
|
The single 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 fixed 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 fixed in the Zip File.
|
<oEntry>
|
<oEntry> specifies the ZipCentralDirectoryRecord object of the (File) Entry that should be fixed in the Zip File.
|
This method returns the (new) Status of the fixed (File) Entry. This value is a Bit Mask. If no Bit is set, then the (File) Entry was successfully fixed, and the returned value will be Zero (0). Otherwise, the appropriate Bit(s) for each of the remaining Errors will still be set. For a List of the possible Define Constants see the :TestEntry() documentation.
|
This method fixes an existing Central Directory Record object -- as far as possible.
|
|
Currently, only lost and artificially created Central Directory records (that are based on an orphaned Local File Record) are fixed, by adding the missing File Attributes. This is required, so that Directories are recognized. All records that are Stored and are Zero (0) bytes long, will be interpreted as Directories. For all other Files, the "A" Archive File Attribute is set. Additional fixes might later be added, though.
|
|
This existing procedure will fix most (if not all) errors that are caused by a missing Central Directory, though.
|
|
Future versions might also check for the validity of File Names, based on allowed characters or other rules, and correct the given File Names to be valid and possibly also unique in the Zip Files. Additional improvements are possible, too.
|
|
This method will also update the (File) Entry's Error/Status Code value and the :lChanged .
|
Open an existing Zip File named "MyArchive.zip" and (try to) fix the third File Entry of that Zip File. Then show the result if that (File) Entry was fixed, and save the changes (if necessary) while closing the Zip File:
|
|
oZip := XbZLibZip():New('MyArchive.zip')
|
if (nStatus := oZip:FixEntry(3)) == XBZ_ENTRY_OK
|
QOut('Entry Number 3 was successfully fixed!')
|
endif
|
oZip:Close()
|