(Tcl) Iterate over Matching Filenames
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. Note: This example requires Chilkat v11.0.0 or greater.
load ./chilkat.dll
set success 0
# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
set zip [new_CkZip]
# Open a .zip containing PEM files, among other things..
set success [CkZip_OpenZip $zip "qa_data/certs/thawte-roots.zip"]
if {$success == 0} then {
puts [CkZip_lastErrorText $zip]
delete_CkZip $zip
exit
}
set entry [new_CkZipEntry]
set pattern "*.pem"
set bHasMoreMatches [CkZip_EntryMatching $zip $pattern $entry]
while {$bHasMoreMatches == 1} {
puts "Entry: [CkZipEntry_fileName $entry]"
# Get the uncommpressed contents of the entry:
set pemStr [CkZipEntry_unzipToString $entry 0 "utf-8"]
puts "$pemStr"
set bHasMoreMatches [CkZipEntry_GetNextMatch $entry $pattern]
}
delete_CkZip $zip
delete_CkZipEntry $entry
|