1 #[test] test_dir()2fn test_dir() { 3 let t = rustix::fs::openat( 4 rustix::fs::cwd(), 5 rustix::cstr!("."), 6 rustix::fs::OFlags::RDONLY | rustix::fs::OFlags::CLOEXEC, 7 rustix::fs::Mode::empty(), 8 ) 9 .unwrap(); 10 11 let dir = rustix::fs::Dir::read_from(&t).unwrap(); 12 13 let _file = rustix::fs::openat( 14 &t, 15 rustix::cstr!("Cargo.toml"), 16 rustix::fs::OFlags::RDONLY | rustix::fs::OFlags::CLOEXEC, 17 rustix::fs::Mode::empty(), 18 ) 19 .unwrap(); 20 21 let mut saw_dot = false; 22 let mut saw_dotdot = false; 23 let mut saw_cargo_toml = false; 24 for entry in dir { 25 let entry = entry.unwrap(); 26 if entry.file_name() == rustix::cstr!(".") { 27 saw_dot = true; 28 } else if entry.file_name() == rustix::cstr!("..") { 29 saw_dotdot = true; 30 } else if entry.file_name() == rustix::cstr!("Cargo.toml") { 31 saw_cargo_toml = true; 32 } 33 } 34 assert!(saw_dot); 35 assert!(saw_dotdot); 36 assert!(saw_cargo_toml); 37 } 38