check out dir
This commit is contained in:
parent
63a3233e12
commit
ab9816ee97
18
src/main.rs
18
src/main.rs
@ -245,8 +245,7 @@ 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();
|
||||||
let data = parse_file(file).unwrap();
|
let data = parse_file(file).unwrap();
|
||||||
@ -282,10 +281,23 @@ 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(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user