From ab9816ee97dc905889527a5cf527bc263227d49f Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 25 Aug 2022 14:45:03 +0300 Subject: [PATCH] check out dir --- src/main.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index b78ecaa..049a466 100644 --- a/src/main.rs +++ b/src/main.rs @@ -245,8 +245,7 @@ fn process_files(files: &&[PathBuf]) { files.iter().for_each(|name| { let name_str = name.to_str().unwrap(); - println!("{:}", name_str); - + // parse txt file let file = archive.by_name(name_str).unwrap(); let data = parse_file(file).unwrap(); @@ -282,10 +281,23 @@ fn main() -> Result<(), Box> { }) .collect(); drop(archive); - + + // check output directory + let out_dir: PathBuf = OUTPUT_PATH.into(); + if out_dir.is_file() { + return Err("output directory is file!".into()); + } + else if !out_dir.exists() { + fs::create_dir_all(out_dir)?; + }; + + println!("processing {} files with {} threads...", source_files.len(), rayon::current_num_threads()); + // split vector and process its parts in parallel split_vec(&source_files, rayon::current_num_threads()) .par_iter() .for_each(process_files); + + println!("done"); Ok(()) }