From 9c7fdfd9d1704622125c4a5057b73e7aa0ee45cd Mon Sep 17 00:00:00 2001 From: Josh Holmer Date: Mon, 6 Nov 2017 18:59:11 -0500 Subject: [PATCH] Fix parsing of glob paths on Windows Closes #90 --- CHANGELOG.md | 3 ++- Cargo.lock | 7 +++++++ Cargo.toml | 34 +++++++++++++++++++++++++--------- src/main.rs | 5 ++++- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e979e45b..c4696a418 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ ### Version 0.18.0 (unreleased) - Bump `itertools` to 0.7 - Bump `image` to 0.17 - - Bump minimum rustc version to 1.20.0 + - [SEMVER_MAJOR] Bump minimum rustc version to 1.20.0 + - Fix parsing of glob paths on Windows ([#90](https://github.com/shssoichiro/oxipng/issues/90)) ### Version 0.17.2 - Bump `image` to 0.16 diff --git a/Cargo.lock b/Cargo.lock index c3b6682c4..a7b5f1a1a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -201,6 +201,11 @@ name = "getopts" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "glob" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "idna" version = "0.1.4" @@ -347,6 +352,7 @@ dependencies = [ "clap 2.27.1 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.169 (registry+https://github.com/rust-lang/crates.io-index)", "crc 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", @@ -680,6 +686,7 @@ dependencies = [ "checksum fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "43f3795b4bae048dc6123a6b972cadde2e676f9ded08aef6bb77f5f157684a82" "checksum futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "118b49cac82e04121117cbd3121ede3147e885627d82c4546b87c702debb90c1" "checksum getopts 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "65922871abd2f101a2eb0eaebadc66668e54a87ad9c3dd82520b5f86ede5eff9" +"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d" "checksum if_chain 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "61bb90bdd39e3af69b0172dfc6130f6cd6332bf040fbb9bdd4401d37adbd48b8" "checksum image 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d1576ffa01849c91b484b95c01d54dddc242b4d50923eaa2d4d74a58c4b9e8fd" diff --git a/Cargo.toml b/Cargo.toml index a7fd4ae4f..1c8b1890a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,19 +1,21 @@ [package] authors = ["Joshua Holmer "] -categories = ["command-line-utilities", "compression"] +categories = [ + "command-line-utilities", + "compression", +] description = "A lossless PNG compression optimizer" documentation = "https://docs.rs/oxipng" -exclude = ["tests/*", "bench/*"] +exclude = [ + "tests/*", + "bench/*", +] homepage = "https://github.com/shssoichiro/oxipng" license = "MIT" name = "oxipng" repository = "https://github.com/shssoichiro/oxipng" version = "0.17.2" -[lib] -name = "oxipng" -path = "src/lib.rs" - [[bin]] doc = false name = "oxipng" @@ -23,6 +25,7 @@ path = "src/main.rs" bit-vec = "^0.4.2" byteorder = "^1.0.0" crc = "^1.2.0" +glob = "0.2.11" itertools = "^0.7.0" libc = "^0.2.4" miniz-sys = "^0.1.7" @@ -48,11 +51,24 @@ optional = true version = "^0.2.0" [features] +binary = [ + "clap", + "regex", +] default = ["binary"] -binary = ["clap", "regex"] +dev = [ + "nightly-binary", + "clippy", +] nightly = [] -nightly-binary = ["binary", "nightly", "regex/simd-accel"] -dev = ["nightly-binary", "clippy"] +nightly-binary = [ + "binary", + "nightly", + "regex/simd-accel", +] +[lib] +name = "oxipng" +path = "src/lib.rs" [profile.dev] opt-level = 2 diff --git a/src/main.rs b/src/main.rs index 3e3ebe30b..4b216fb44 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,10 +8,12 @@ #![deny(missing_debug_implementations, missing_copy_implementations)] extern crate clap; +extern crate glob; extern crate oxipng; extern crate regex; use clap::{App, Arg, ArgMatches}; +use glob::glob; use oxipng::colors::AlphaOptim; use oxipng::deflate::Deflaters; use oxipng::headers::Headers; @@ -235,7 +237,8 @@ fn main() { matches .values_of("files") .unwrap() - .map(PathBuf::from) + .map(|pattern| glob(pattern).expect("Failed to parse input file path")) + .flat_map(|paths| paths.into_iter().map(|path| path.expect("Failed to parse input file path"))) .collect(), &opts, );