symbols/
symbols.rs

1//! Lists symbols in an archive.
2//!
3//! To list all symbols in an archive, run:
4//!
5//! ```shell
6//! cargo run --example symbols <path/to/archive.a>
7//! ```
8
9extern crate ar;
10
11use std::env;
12use std::fs::File;
13use std::path::Path;
14
15fn main() {
16    let num_args = env::args().count();
17    if num_args != 2 {
18        println!("Usage: symbols <path/to/archive.a>");
19        return;
20    }
21
22    let input_path = env::args().nth(1).unwrap();
23    let input_path = Path::new(&input_path);
24    let input_file =
25        File::open(input_path).expect("failed to open input file");
26    let mut archive = ar::Archive::new(input_file);
27
28    for symbol in archive.symbols().expect("failed to parse symbols") {
29        println!("{}", String::from_utf8_lossy(symbol));
30    }
31}