Skip to content

Commit

Permalink
Assert that output directory exists
Browse files Browse the repository at this point in the history
  • Loading branch information
kkafar committed Oct 9, 2023
1 parent 55fa7f7 commit cff5813
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/jssp/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ fn run_with_ecrs(instance: JsspInstance, _args: Args) {

fn run() {
let args = cli::parse_args();


util::assert_dir_exists(args.output_dir.as_ref());
let event_map = util::create_event_map(args.output_dir.as_ref());
if let Err(err) = logging::init_logging(&event_map) {
panic!("Logger initialization failed with error: {err}");
Expand Down
11 changes: 11 additions & 0 deletions examples/jssp/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,14 @@ pub fn create_event_map(base_dir: &Path) -> HashMap<String, PathBuf> {
("iterinfo".to_owned(), base_dir.join("event_iterinfo.csv"))
])
}

pub fn assert_dir_exists(dir: &Path) {
if dir.is_dir() {
return;
}

match std::fs::create_dir_all(dir) {
Ok(()) => return,
Err(err) => panic!("Failed to create outuput directory with error {err}"),
};
}

0 comments on commit cff5813

Please sign in to comment.