check out dir

This commit is contained in:
Dmitry Belyaev 2022-08-25 14:45:03 +03:00
parent 63a3233e12
commit ab9816ee97
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3

View File

@ -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<dyn std::error::Error>> {
})
.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(())
}