]>
Commit | Line | Data |
---|---|---|
6cd4f635 WB |
1 | use pxar::decoder::aio::Decoder; |
2 | ||
3 | #[tokio::main] | |
4 | async fn main() { | |
5 | let mut args = std::env::args_os().skip(1); | |
6 | ||
7 | let file = args.next().expect("expected a file name"); | |
8 | let file = tokio::fs::File::open(file) | |
9 | .await | |
10 | .expect("failed to open file"); | |
11 | ||
12 | let mut reader = Decoder::from_tokio(file) | |
13 | .await | |
14 | .expect("failed to open pxar archive contents"); | |
15 | let mut i = 0; | |
16 | while let Some(entry) = reader.next().await { | |
17 | println!("{:#?}", entry.expect("failed to parse entry").path()); | |
18 | i += 1; | |
19 | if i == 2 { | |
20 | break; | |
21 | } | |
22 | } | |
23 | ||
24 | // Use a Stream for the remaining entries: | |
25 | use futures::stream::StreamExt; | |
26 | ||
27 | let mut stream = reader.into_stream(); | |
28 | ||
29 | while let Some(entry) = stream.next().await { | |
30 | println!("{:#?}", entry.expect("failed to parse entry").path()); | |
31 | } | |
32 | } |