Check validity of output file path

This commit is contained in:
Zen 2021-08-06 19:06:39 +03:00
parent 253b2bc551
commit c47e19bead

View file

@ -1,4 +1,5 @@
use std::path::Path; use std::path::{Path, PathBuf};
use std::process::exit;
use av1an_cli::Args; use av1an_cli::Args;
use av1an_core::vapoursynth; use av1an_core::vapoursynth;
@ -42,7 +43,14 @@ pub fn main() {
Vec::new() Vec::new()
}, },
output_file: if let Some(output) = args.output_file { output_file: if let Some(output) = args.output_file {
if !output.parent().unwrap().exists() && output.parent().unwrap() == PathBuf::new() {
output.to_str().unwrap().to_owned() output.to_str().unwrap().to_owned()
} else if output.parent().unwrap().exists() {
output.to_str().unwrap().to_owned()
} else {
println!("Path to file is invalid {:#?}", &output);
exit(1);
}
} else { } else {
format!( format!(
"{}_{}.mkv", "{}_{}.mkv",