Skip to content

Commit

Permalink
Release 0.6.1
Browse files Browse the repository at this point in the history
* pass through zip and IO errors
* replaces all instances of unwrap()
* read::ZipArchiveExtensions now returns ZipResult<PathBuf> instead of PathBuf as the underlying operation can return an error.

Co-authored-by: Matthias Friedrich

* Adds tests; extends try_is_zip method so that it can detect different archive formats.
* cargo fmt
* Updates create version and README.md
* Updates LICENSE

Co-authored-by: T.C. Hollingsworth <tchollingsworth@gmail.com>
  • Loading branch information
matzefriedrich and tchollingsworth authored Jul 29, 2021
1 parent 7b3f17b commit ce3cf75
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "zip-extensions"
version = "0.6.0"
version = "0.6.1"
authors = ["Matthias Friedrich <rushiblegit@gmail.com>"]
edition = "2018"
description = "An extension create for zip."
description = "An extension crate for zip."
readme = "README.md"
repository = "https://github.com/matzefriedrich/zip-extensions-rs"
license = "MIT"
Expand All @@ -15,4 +15,4 @@ exclude = [
]

[dependencies]
zip = "0.5.8"
zip = "0.5"
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Matthias Friedrich
Copyright (c) 2020 - 2021 Matthias Friedrich

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Add the following dependencies to the `Cargo.toml` file.

````toml
[dependencies]
zip = "0.5.8"
zip-extensions = "0.6.0"
zip = "0.5"
zip-extensions = "0.6"
````

See https://github.com/mvdnes/zip-rs fur further information about `zip` dependencies.
Expand All @@ -30,9 +30,9 @@ use std::fs::File;
use zip_extensions::read::ZipArchiveExtensions;
...

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

Alternatively, the `zip_extract` helper can be used.
Expand All @@ -42,7 +42,7 @@ use zip_extensions::*;
...
let archive_file: PathBuf = ...
let target_dir: PathBuf = ...
zip_extract(&archive_file, &target_dir).unwrap();
zip_extract(&archive_file, &target_dir)?;
````

### Extracting an archive entry into memory
Expand All @@ -52,8 +52,8 @@ The `zip_extract_file_to_memory` method can be used to extract entries ad-hoc in
````rust
use zip_extensions::*;

let archive_file = PathBuf::from_str(r#"Baloo_Da_2.zip"#).unwrap();
let entry_path = PathBuf::from_str("BalooDa2-Medium.ttf").unwrap();
let archive_file = PathBuf::from_str(r#"Baloo_Da_2.zip"#)?;
let entry_path = PathBuf::from_str("BalooDa2-Medium.ttf")?;

let mut buffer : Vec<u8> = vec![];
match zip_extract_file_to_memory(&archive_file, &entry_path, &mut buffer) {
Expand All @@ -71,9 +71,9 @@ use zip::ZipWriter;
use zip_extensions::write::ZipWriterExtensions;
...

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

Alternatively, the `zip_create_from_directory` helper can be used.
Expand All @@ -83,5 +83,5 @@ use zip_extensions::*;
...
let archive_file: PathBuf = ...
let source_dir: PathBuf = ...
zip_create_from_directory(&archive_file, &source_dir).unwrap();
zip_create_from_directory(&archive_file, &source_dir)?;
````

0 comments on commit ce3cf75

Please sign in to comment.