// Run: aji run --grant fs_read=fs.read:/in --grant fs_write=fs.write:/out \ // --vfs '/in/data.txt=some text' examples/file_copy.aji module examples.file_copy fn copy(input: mut>, output: mut>) -> void effects [fs.read, fs.write] { var buf: [u8; 64] = zero; loop { let n = fs.read(input, mut buf) or trap; if n == 0 { break; } fs.write_all(output, ref buf[0..n]) or trap; } } fn main(fs_read: cap, fs_write: cap) -> void effects [fs.read, fs.write] { let input = fs.open_read(fs_read, b"/in/data.txt") or trap; let output = fs.create(fs_write, b"/out/copy.txt") or trap; copy(mut input, mut output); fs.close(move input) or trap; fs.close(move output) or trap; }