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(()) }