1 #![expect(unsafe_op_in_unsafe_fn, reason = "old code, not worth updating yet")] 2 3 use std::{env, process}; 4 use test_programs::preview1::open_scratch_directory; 5 6 unsafe fn try_path_open(dir_fd: wasip1::Fd) { 7 let _fd = wasip1::path_open(dir_fd, 0, ".", 0, 0, 0, wasip1::FDFLAGS_NONBLOCK) 8 .expect("opening the dir"); 9 } 10 11 fn main() { 12 let mut args = env::args(); 13 let prog = args.next().unwrap(); 14 let arg = if let Some(arg) = args.next() { 15 arg 16 } else { 17 eprintln!("usage: {prog} <scratch directory>"); 18 process::exit(1); 19 }; 20 21 // Open scratch directory 22 let dir_fd = match open_scratch_directory(&arg) { 23 Ok(dir_fd) => dir_fd, 24 Err(err) => { 25 eprintln!("{err}"); 26 process::exit(1) 27 } 28 }; 29 30 // Run the tests. 31 unsafe { try_path_open(dir_fd) } 32 } 33