From ce3cf757dcb4a110ba87c286b1c8624ea12e6116 Mon Sep 17 00:00:00 2001 From: Matthias Friedrich Date: Fri, 30 Jul 2021 00:55:50 +0200 Subject: [PATCH] Release 0.6.1 * pass through zip and IO errors * replaces all instances of unwrap() * read::ZipArchiveExtensions now returns ZipResult 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 --- Cargo.toml | 6 +++--- LICENSE | 2 +- README.md | 22 +++++++++++----------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1c15d9e..d47c45a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "zip-extensions" -version = "0.6.0" +version = "0.6.1" authors = ["Matthias Friedrich "] 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" @@ -15,4 +15,4 @@ exclude = [ ] [dependencies] -zip = "0.5.8" +zip = "0.5" diff --git a/LICENSE b/LICENSE index 002c26a..fd8806a 100644 --- a/LICENSE +++ b/LICENSE @@ -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 diff --git a/README.md b/README.md index 3ef348d..a114e3c 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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. @@ -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 @@ -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 = vec![]; match zip_extract_file_to_memory(&archive_file, &entry_path, &mut buffer) { @@ -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. @@ -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)?; ```` \ No newline at end of file