Delphi DLL Requires Chilkat v11.0.0+
Delphi DLL
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 Delphi DLL Downloads
var
success: Boolean;
zip: HCkZip;
entry: HCkZipEntry;
pemStr: PWideChar;
pattern: PWideChar;
bHasMoreMatches: Boolean;
begin
success := False;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
zip := CkZip_Create();
// Open a .zip containing PEM files, among other things..
success := CkZip_OpenZip(zip,'qa_data/certs/thawte-roots.zip');
if (success = False) then
begin
Memo1.Lines.Add(CkZip__lastErrorText(zip));
Exit;
end;
entry := CkZipEntry_Create();
pattern := '*.pem';
bHasMoreMatches := CkZip_EntryMatching(zip,pattern,entry);
while bHasMoreMatches = True do
begin
Memo1.Lines.Add('Entry: ' + CkZipEntry__fileName(entry));
// Get the uncommpressed contents of the entry:
pemStr := CkZipEntry__unzipToString(entry,0,'utf-8');
Memo1.Lines.Add(pemStr);
bHasMoreMatches := CkZipEntry_GetNextMatch(entry,pattern);
end;
CkZip_Dispose(zip);
CkZipEntry_Dispose(entry);