create image output parent directory if nonexistent
This commit is contained in:
parent
9025e0e461
commit
92196dcbf8
|
|
@ -1,5 +1,5 @@
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use std::time::SystemTime;
|
use std::{fs, time::SystemTime};
|
||||||
|
|
||||||
use draw::{StackedConfig, StackedSeries, StackedSeriesConfig, stacked};
|
use draw::{StackedConfig, StackedSeries, StackedSeriesConfig, stacked};
|
||||||
use imageproc::image::codecs::pnm::SampleEncoding;
|
use imageproc::image::codecs::pnm::SampleEncoding;
|
||||||
|
|
@ -95,6 +95,15 @@ impl Runner {
|
||||||
self.last_sample = now;
|
self.last_sample = now;
|
||||||
|
|
||||||
for g in &mut self.graphs {
|
for g in &mut self.graphs {
|
||||||
|
let path = std::path::Path::new(&g.series.config.path)
|
||||||
|
.parent()
|
||||||
|
.expect("wrong target directory");
|
||||||
|
if !fs::exists(path).unwrap_or(false) {
|
||||||
|
fs::create_dir(path).map_err(|_| {
|
||||||
|
RunnerError::CouldNotSaveImage("cannot create parent directory".to_string())
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
// fill in empty samples for missing data
|
// fill in empty samples for missing data
|
||||||
if dt >= 2. {
|
if dt >= 2. {
|
||||||
let dt_round = dt.round() as u32;
|
let dt_round = dt.round() as u32;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue