MCPcopy Create free account
hub / github.com/PerroEngine/Perro / extract_zip_file

Function extract_zip_file

perro_source/io_stack/perro_io/src/zip.rs:63–87  ·  view source on GitHub ↗
(path: impl AsRef<Path>, output_dir: impl AsRef<Path>)

Source from the content-addressed store, hash-verified

61 }
62 zip.finish().map_err(zip_error_to_io)?;
63 Ok(())
64}
65
66pub fn list_zip_file(path: impl AsRef<Path>) -> io::Result<Vec<String>> {
67 list_zip_file_with_limits(path, ZipLimits::default())
68}
69
70pub fn list_zip_file_with_limits(
71 path: impl AsRef<Path>,
72 limits: ZipLimits,
73) -> io::Result<Vec<String>> {
74 let file = fs::File::open(path)?;
75 let mut archive = zip::ZipArchive::new(file).map_err(zip_error_to_io)?;
76 check_entry_count(archive.len(), limits)?;
77 let mut out = Vec::with_capacity(archive.len());
78 for index in 0..archive.len() {
79 let file = archive.by_index(index).map_err(zip_error_to_io)?;
80 out.push(file.name().to_string());
81 }
82 out.sort();
83 Ok(out)
84}
85
86pub fn read_zip_file_entry(path: impl AsRef<Path>, name: &str) -> io::Result<Vec<u8>> {
87 read_zip_file_entry_with_limits(path, name, ZipLimits::default())
88}
89
90pub fn read_zip_file_entry_with_limits(

Callers 1

extract_allFunction · 0.85

Calls 6

ensure_inside_dirFunction · 0.85
joinMethod · 0.80
parentMethod · 0.80
createFunction · 0.50
as_refMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected