FindEntry()
|
Previous Top Next |
:FindEntry(<cFileName>) --> oZipCentralDirectoryRecord | NIL
|
<cFileName>
|
<cFileName> specifies the File Name of the existing Central Directory Record Entry that should be found in the Zip File.
|
If a (File) Entry with the specified File Name exists, the found Central Directory Record -- a ZipCentralDirectoryRecord object -- is returned, otherwise, if no exact match could be found, NIL is returned.
|
This method searches the Zip File's Directory for a specific (File) Entry, based on the given File Name <cFileName>. This Search is case-insensitive, but requires the File Name to have the exact same length as <cFileName>, which means that <cFileName> must also include any relative Path (Directory Name) information that might be saved in the requested (File) Entry!
|
|
The function will either return the found Central Directory Record as an ZipCentralDirectoryRecord object, or NIL, if an exact match could not be found.
|
|
Future versions might allow case-sensitive searches, or find partial File Names, or ignore relative paths, or even use Wild Card characters or Regular Expressions in the search. But because such inexact searches might return the first of multiple possible (or even all) valid records, this option cannot be used for many of the internal tasks that the :FindEntry() method is currently used for! One option would be to add a new method, like :FindEntries(), which would return an Array of possible records.
|
Open an existing Zip File named "MyArchive.zip" and (try to) find a File Entry named "MyDir\TestFile.xxx". If it was found, show some detail information, otherwise show an error message, and then close the Zip File:
|
|
oZip := XbZLibZip():New('MyArchive.zip')
|
cFile := 'MyDir\TestFile.xxx'
|
if (oCDRec := oZip:FindEntry(cFile)) # NIL
|
QOut('File Name in Zip File: "' + oCDRec:FileName + '"')
|
QOut('Original File Size: ' + alltrim(str(oCDRec:UnCompSize)))
|
else
|
QOut('File: "' + cFile + '" does not exist in this Zip File!')
|
endif
|
oZip:Close()
|