1extern crate ar;
17
18use std::env;
19use std::fs::File;
20use std::path::Path;
21
22fn main() {
23 let num_args = env::args().count();
24 if num_args < 3 {
25 println!("Usage: create <outpath> <inpath> [<inpath>...]");
26 return;
27 }
28
29 let output_path = env::args().nth(1).unwrap();
30 let output_path = Path::new(&output_path);
31 let output_file =
32 File::create(output_path).expect("failed to open output file");
33 let mut builder = ar::Builder::new(output_file);
34
35 for index in 2..num_args {
36 let input_path = env::args().nth(index).unwrap();
37 let input_path = Path::new(&input_path);
38 builder
39 .append_path(input_path)
40 .expect(&format!("failed to add {:?} to archive", input_path));
41 }
42}