An extension crate for https://github.com/mvdnes/zip-rs that provides high-level functions for common ZIP tasks, such as extracting archives to a directory.
Add the following dependencies to the Cargo.toml
file.
toml
[dependencies]
zip = "0.5.5"
zip-extensions = "0.1.4"
See https://github.com/mvdnes/zip-rs fur further information about zip
dependencies.
The ZipArchiveExtensions
trait provides the extract
method that can be used to unzip an archive to a directory.
````rust use std::fs::File; use zipextensions::readextensions::ZipArchiveExtensions; ...
let file = File::create(archivefile).unwrap(); let mut archive = zip::ZipArchive::new(file).unwrap(); archive.extract(&targetpath).unwrap(); ````
The ZipWriterExtensions
trait provides the create_from_directory
and create_from_directory_with_options
methods that can be used to add an entire directory hierarchy to an archive.
````rust use zip::ZipWriter; use zipextensions::writeextensions::ZipWriterExtensions; ...
let file = File::create(archivefile).unwrap(); let mut zip = ZipWriter::new(file); zip.createfromdirectory(&sourcepath).unwrap() ````