...

Text file src/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/example/testdata/cargo-wasi/cat.rs

Documentation: github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/example/testdata/cargo-wasi

     1use std::env;
     2use std::fs::File;
     3use std::io;
     4use std::io::Write;
     5use std::process::exit;
     6
     7fn 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}

View as plain text