Fix issue where output directory would not be created if it did not exist
This commit is contained in:
parent
f8deac1cea
commit
fac83c023d
2 changed files with 10 additions and 1 deletions
|
|
@ -1,3 +1,6 @@
|
||||||
|
**Version 0.5.1 (unreleased)**
|
||||||
|
- Fix issue where output directory would not be created if it did not exist
|
||||||
|
|
||||||
**Version 0.5.0**
|
**Version 0.5.0**
|
||||||
- [SEMVER_MINOR] Palette entries can now reduced, on by default ([#11](https://github.com/shssoichiro/oxipng/issues/11))
|
- [SEMVER_MINOR] Palette entries can now reduced, on by default ([#11](https://github.com/shssoichiro/oxipng/issues/11))
|
||||||
- Don't report that we are in pretend mode if verbosity is set to none
|
- Don't report that we are in pretend mode if verbosity is set to none
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ use clap::{App, Arg, ArgMatches};
|
||||||
use oxipng::png;
|
use oxipng::png;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
use std::fs::DirBuilder;
|
||||||
use std::io::{Write, stderr};
|
use std::io::{Write, stderr};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
|
@ -410,7 +411,12 @@ fn parse_opts_into_struct(matches: &ArgMatches, opts: &mut oxipng::Options) -> R
|
||||||
if let Some(x) = matches.value_of("output_dir") {
|
if let Some(x) = matches.value_of("output_dir") {
|
||||||
let path = PathBuf::from(x);
|
let path = PathBuf::from(x);
|
||||||
if !path.exists() {
|
if !path.exists() {
|
||||||
|
match DirBuilder::new()
|
||||||
|
.recursive(true)
|
||||||
|
.create(&path) {
|
||||||
|
Ok(_) => (),
|
||||||
|
Err(x) => return Err(format!("Could not create output directory {}", x)),
|
||||||
|
};
|
||||||
} else if !path.is_dir() {
|
} else if !path.is_dir() {
|
||||||
return Err(format!("{} is an existing file (not a directory), cannot create directory",
|
return Err(format!("{} is an existing file (not a directory), cannot create directory",
|
||||||
x));
|
x));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue