Crates.io | zip_structs |
lib.rs | zip_structs |
version | 0.2.1 |
source | src |
created_at | 2021-02-22 13:15:23.943411 |
updated_at | 2022-11-24 12:42:51.414496 |
description | ZIP archives structures handling library |
homepage | |
repository | https://github.com/tats-u/rust-zip-structs/ |
max_upload_size | |
id | 358989 |
size | 41,912 |
This crates handles structures in ZIP files.
Add the following line to [dependencies]
in your Cargo.toml
.
zip_structs = "^0.2"
Breaking changes to the API are planned for the future. Therefore, it is strongly recommended to use this versioning format.
use std::io::BufReader;
use std::fs::File;
use oem_cp::decode_string_complete_table;
use oem_cp::code_table::DECODING_TABLE_CP437;
use zip_structs::zip_central_directory::ZipCDEntry;
use zip_structs::zip_eocd::ZipEOCD;
use zip_structs::zip_local_file_header::ZipLocalFileHeader;
let mut zip_file = BufReader(File::open("path/to/archive.zip")?);
let eocd = ZipEOCD::from_reader(&mut zip_file)?;
let cd_list = ZipCDEntry::all_from_eocd(&mut zip_file, &eocd)?;
// Show file names in the ZIP archive
for cd in &cd_list {
println!(
"{}",
if cd.is_encoded_in_utf8() {
String::from_utf8_lossy(&cd.file_name_raw);
} else {
decode_string_complete_table(&cd.file_name_raw, DECODING_TABLE_CP437)
}
);
let local_file_header = ZipLocalFileHeader::from_central_directory(&mut zip_file, &cd)?;
do_something(&local_file_header);
}
There are some libraries providing more abstract and higher-level APIs.
zip
rc-zip
These libraries do not handle general purpose bit flags in central directories and local file headers. rc-zip
cannot handle file names encoded in other than UTF-8.
vfs-zip
This library provides virtual file system, not structures in ZIP archives.
This library has not supported ZIP64 yet.
MIT