Logo

Programming-Idioms

History of Idiom 217 > diff from v4 to v5

Edit summary for version 5 by swedebugia:
New Rust implementation by user [swedebugia]

Version 4

2020-01-02, 10:53:32

Version 5

2020-04-16, 16:35:52

Idiom #217 Create a Zip archive

Create a zip-file with filename name and add the files listed in list to that zip-file.

Idiom #217 Create a Zip archive

Create a zip-file with filename name and add the files listed in list to that zip-file.

Extra Keywords
zip
Extra Keywords
zip
Imports
use zip::write::FileOptions;
Code
let path = std::path::Path::new(_name);
let file = std::fs::File::create(&path).unwrap();
let mut zip = zip::ZipWriter::new(file); zip.start_file("readme.txt", FileOptions::default())?;                                                          
zip.write_all(b"Hello, World!\n")?;
zip.finish()?;
Comments bubble
zip.finish() returns a Result.
Doc URL
http://mvdnes.github.io/rust-docs/zip-rs/zip/index.html
Origin
https://github.com/mvdnes/zip-rs/blob/master/examples/write_sample.rs