Lua Requires Chilkat v11.0.0+
Lua
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 Lua Downloads
local chilkat = require("chilkat")
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local zip = chilkat.Zip.new()
-- Open a .zip containing PEM files, among other things..
local success = zip:open_zip("qa_data/certs/thawte-roots.zip")
if not success then
print(zip.last_error_text)
return
end
local entry = chilkat.ZipEntry.new()
local pemStr = ""
local pattern = "*.pem"
local bHasMoreMatches = zip:entry_matching(pattern, entry)
while bHasMoreMatches do
print("Entry: " .. entry.file_name)
-- Get the uncommpressed contents of the entry:
pemStr = entry:unzip_to_string(0, "utf-8")
print(pemStr)
bHasMoreMatches = entry:get_next_match(pattern)
end