github.com/wasilibs/wazerox@v0.0.0-20240124024944-4923be63ab5f/imports/wasi_snapshot_preview1/example/testdata/cargo-wasi/cat.rs (about) 1 use std::env; 2 use std::fs::File; 3 use std::io; 4 use std::io::Write; 5 use std::process::exit; 6 7 fn main() { 8 // Start at arg[1] because args[0] is the program name. 9 for path in env::args().skip(1) { 10 if let Ok(mut file) = File::open(&path) { 11 io::copy(&mut file, &mut io::stdout()).unwrap(); 12 } else { 13 writeln!(io::stderr(), "error opening: {}: No such file or directory", path).unwrap(); 14 exit(1); 15 } 16 } 17 }