Skip to content

Commit

Permalink
Updates the readme
Browse files Browse the repository at this point in the history
  • Loading branch information
matzefriedrich committed Mar 19, 2020
1 parent 9849e4d commit f283b6d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,23 @@ The `ZipArchiveExtensions` trait provides the `extract` method that can be used
````rust
use std::fs::File;
use zip_extensions::read_extensions::ZipArchiveExtensions;
...

let file = File::open(archive_file).unwrap();
let file = File::create(archive_file).unwrap();
let mut archive = zip::ZipArchive::new(file).unwrap();
archive.extract(&target_path).unwrap();
````

### Creating an archive from a directory

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 a directory.

````rust
use zip::ZipWriter;
use zip_extensions::write_extensions::ZipWriterExtensions;
...

let file = File::create(archive_file).unwrap();
let mut zip = ZipWriter::new(file);
zip.create_from_directory(&source_path).unwrap()
````

0 comments on commit f283b6d

Please sign in to comment.