Skip to content

Commit cf20cad

Browse files
elbertronnieKeavon
authored andcommitted
Create output folder if it doesn't exist
1 parent 3685935 commit cf20cad

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

libraries/raw-rs/tests/tests.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use image::{ColorType, ImageEncoder};
88
use libraw::Processor;
99
use std::collections::HashMap;
1010
use std::fmt::Write;
11-
use std::fs::{read_dir, File};
11+
use std::fs::{create_dir, metadata, read_dir, File};
1212
use std::io::{BufWriter, Cursor, Read};
1313
use std::path::{Path, PathBuf};
1414
use std::time::Duration;
@@ -73,6 +73,11 @@ fn store_image(path: &Path, suffix: &str, data: &mut [u8], width: usize, height:
7373
output_path.push(parent);
7474
}
7575
output_path.push("output");
76+
77+
if metadata(&output_path).is_err() {
78+
create_dir(&output_path).unwrap();
79+
}
80+
7681
if let Some(filename) = path.file_stem() {
7782
let new_filename = format!("{}_{}.{}", filename.to_string_lossy(), suffix, "png");
7883
output_path.push(new_filename);

0 commit comments

Comments
 (0)