(path: impl AsRef<Path>, output_dir: impl AsRef<Path>)
| 61 | } |
| 62 | zip.finish().map_err(zip_error_to_io)?; |
| 63 | Ok(()) |
| 64 | } |
| 65 | |
| 66 | pub fn list_zip_file(path: impl AsRef<Path>) -> io::Result<Vec<String>> { |
| 67 | list_zip_file_with_limits(path, ZipLimits::default()) |
| 68 | } |
| 69 | |
| 70 | pub 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 | |
| 86 | pub 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 | |
| 90 | pub fn read_zip_file_entry_with_limits( |
no test coverage detected