| 525 | } |
| 526 | |
| 527 | fn write_parsed(path: &str) { |
| 528 | let input = std::path::Path::new(path); |
| 529 | let stem = input.file_stem() |
| 530 | .map(|s| s.to_string_lossy().into_owned()) |
| 531 | .unwrap_or_else(|| path.to_owned()); |
| 532 | let out_path = format!("parsed/{stem}.json"); |
| 533 | |
| 534 | eprint!("{path} ... "); |
| 535 | let packets = parse_file(path); |
| 536 | fs::create_dir_all("parsed").expect("Cannot create ./parsed"); |
| 537 | let out = File::create(&out_path) |
| 538 | .unwrap_or_else(|e| panic!("Cannot create {out_path}: {e}")); |
| 539 | serde_json::to_writer_pretty(BufWriter::new(out), &packets) |
| 540 | .expect("JSON serialization failed"); |
| 541 | eprintln!("wrote {} packets → {out_path}", packets.len()); |
| 542 | } |
| 543 | |
| 544 | fn main() { |
| 545 | let args: Vec<String> = env::args().skip(1).collect(); |