]> git.proxmox.com Git - pxar.git/blob - examples/randaccess.rs
don't hold temp buffer mutex across await point
[pxar.git] / examples / randaccess.rs
1 use std::sync::Arc;
2
3 use pxar::accessor::Accessor;
4
5 fn main() {
6 let mut args = std::env::args_os().skip(1);
7
8 let file = args.next().expect("expected a file name");
9 let file = std::fs::File::open(file).expect("failed to open file");
10 let file = Arc::new(file);
11
12 let accessor = Accessor::from_file_ref(file).expect("failed to open file");
13 let dir = accessor
14 .open_root_ref()
15 .expect("failed to open archive root directory");
16 for i in dir.decode_full().expect("failed to access root directory") {
17 println!("{:#?}", i.expect("failed to parse entry").path());
18 }
19
20 let da = dir
21 .lookup("da")
22 .expect("error looking up da/")
23 .expect("failed to lookup da/");
24 dir.lookup("db").expect("failed to lookup db");
25 dir.lookup("root1.txt").expect("failed to lookup root1.txt");
26 dir.lookup("root2.txt").expect("failed to lookup root2.txt");
27
28 println!("{:?}", da.entry());
29 let da = da.enter_directory().expect("failed to enter /da directory");
30 for i in da.decode_full().expect("failed to access /da directory") {
31 println!(
32 " ==> {:#?}",
33 i.expect("failed to parse /da file entry").path()
34 );
35 }
36
37 for i in dir.read_dir() {
38 let i = i.expect("failed to read directory entry");
39 println!("read_dir => {:?}", i.file_name());
40 }
41 }