]>
git.proxmox.com Git - cargo.git/blob - vendor/tar-0.4.14/examples/extract_file.rs
1 //! An example of extracting a file in an archive.
3 //! Takes a tarball on standard input, looks for an entry with a listed file
4 //! name as the first argument provided, and then prints the contents of that
9 use std
::io
::{stdin, stdout, copy}
;
10 use std
::env
::args_os
;
16 let first_arg
= args_os().skip(1).next().unwrap();
17 let filename
= Path
::new(&first_arg
);
18 let mut ar
= Archive
::new(stdin());
19 for file
in ar
.entries().unwrap() {
20 let mut f
= file
.unwrap();
21 if f
.path().unwrap() == filename
{
22 copy(&mut f
, &mut stdout()).unwrap();