Xbase++ Requires Chilkat v11.0.0+
Xbase++
Iterate over Matching Filenames
See more Zip Examples
Iterates over files within a .zip that match a pattern. In this case, the pattern is "*.pem". This example will open a .zip containing files of type .txt, .cer, .pem, and possibly others, and will iterate over only the .pem files.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oZip
LOCAL oEntry
LOCAL cPemStr
LOCAL cPattern
LOCAL nBHasMoreMatches
nSuccess := 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oZip := CreateObject("Chilkat.Zip")
// Open a .zip containing PEM files, among other things..
nSuccess := oZip:OpenZip("qa_data/certs/thawte-roots.zip")
IF (nSuccess == 0)
? oZip:LastErrorText
oZip:destroy()
RETURN
ENDIF
oEntry := CreateObject("Chilkat.ZipEntry")
cPattern := "*.pem"
nBHasMoreMatches := oZip:EntryMatching(cPattern, oEntry)
DO WHILE nBHasMoreMatches == 1
? "Entry: " + oEntry:FileName
// Get the uncommpressed contents of the entry:
cPemStr := oEntry:UnzipToString(0, "utf-8")
? cPemStr
nBHasMoreMatches := oEntry:GetNextMatch(cPattern)
ENDDO
oZip:destroy()
oEntry:destroy()