mirror of
https://codeberg.org/icewind/tf-log-parser.git
synced 2026-06-03 18:24:09 +02:00
quote in name handling somewhat
This commit is contained in:
parent
484fd735d1
commit
de2e940974
5 changed files with 81 additions and 9 deletions
28
examples/dir.rs
Normal file
28
examples/dir.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
use main_error::MainError;
|
||||
use std::env::args;
|
||||
use std::ffi::OsStr;
|
||||
use std::fs;
|
||||
use tf_log_parser::parse;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
fn main() -> Result<(), MainError> {
|
||||
let path = args().nth(1).expect("No path provided");
|
||||
for entry in WalkDir::new(path) {
|
||||
let entry = entry?;
|
||||
let path = entry.path();
|
||||
if path.extension() == Some(OsStr::new("log")) {
|
||||
print!("{} - ", path.display());
|
||||
let input = match fs::read_to_string(path) {
|
||||
Ok(input) => input,
|
||||
Err(e) => {
|
||||
println!("failed to read file: {}", e);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let (output, _) = parse(&input)?;
|
||||
println!("{} messages", output.chat.len());
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue