From 02468bcf3a50a1d94e8b791604c077feabfa9c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Tue, 12 Sep 2017 15:33:18 +0200 Subject: [PATCH] handle_optimization: skip files that do not end in .png --- src/main.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main.rs b/src/main.rs index fa9b81c5..9764872b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -258,6 +258,20 @@ fn handle_optimization(inputs: Vec, opts: &Options) { eprintln!("{} is a directory, skipping", input.display()); } continue; + } else { // input is a file + let ext = input.extension(); + match ext { + Some(ext) => { + if ext != "png" { // not .png + eprintln!("{} is not .png, skipping", input.display()); + continue; + } + } + _ => { // no file extension + eprintln!("{} is not .png, no file extension, skipping", input.display()); + continue; + } + } } if let Some(ref out_dir) = current_opts.out_dir { current_opts.out_file = out_dir.join(input.file_name().unwrap());