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,7 +245,6 @@ fn process_files(files: &&[PathBuf]) {
files.iter().for_each(|name| { files.iter().for_each(|name| {
let name_str = name.to_str().unwrap(); let name_str = name.to_str().unwrap();
println!("{:}", name_str);
// parse txt file // parse txt file
let file = archive.by_name(name_str).unwrap(); let file = archive.by_name(name_str).unwrap();
@ -283,9 +282,22 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.collect(); .collect();
drop(archive); 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 vector and process its parts in parallel
split_vec(&source_files, rayon::current_num_threads()) split_vec(&source_files, rayon::current_num_threads())
.par_iter() .par_iter()
.for_each(process_files); .for_each(process_files);
println!("done");
Ok(()) Ok(())
} }