Rust Requires Chilkat v11.0.0+
Rust
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 Rust Downloads
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let zip = chilkat::Zip::new();
// Open a .zip containing PEM files, among other things..
if zip.open_zip("qa_data/certs/thawte-roots.zip").is_err() {
println!("{}", zip.last_error_text());
return;
}
let entry = chilkat::ZipEntry::new();
let mut pem_str = String::new();
let pattern = "*.pem".to_string();
let mut b_has_more_matches = zip.entry_matching(&pattern, &entry).is_ok();
while b_has_more_matches {
println!("Entry: {}", entry.file_name());
// Get the uncommpressed contents of the entry:
pem_str = entry.unzip_to_string(0, "utf-8").unwrap_or_default();
println!("{}", pem_str);
b_has_more_matches = entry.get_next_match(&pattern).is_ok();
}