Initial import: Aji 0.1 draft spec and Zig scaffolding
Draft specification, RFCs, reference registries and examples, plus the reference-implementation skeleton: build.zig, diagnostic envelope with error-code registry synced to docs, aji CLI, conformance runner with seed tests, CI and contributor docs.
This commit is contained in:
commit
17a55a7fef
67 files changed
+4197
No files matched your search
@@ -0,0 +1,32 @@
|
||||
module examples.file_copy;
|
||||
|
||||
fn copy(
|
||||
fs_read: cap<fs.read>,
|
||||
fs_write: cap<fs.write>,
|
||||
src: slice<u8>,
|
||||
dst: slice<u8>,
|
||||
alloc: cap<mem.alloc>
|
||||
) -> Result<void, IoError>
|
||||
effects [mem.alloc, fs.read, fs.write]
|
||||
{
|
||||
let input = fs.open_read(fs_read, src)?;
|
||||
defer fs.close(move input);
|
||||
|
||||
let output = fs.open_write(fs_write, dst)?;
|
||||
defer fs.close(move output);
|
||||
|
||||
var region = region.create(alloc, limit = 64 KiB)?;
|
||||
defer region.destroy(move region);
|
||||
|
||||
let buffer = region.alloc_zeroed_array<u8>(mut region, 64 KiB)?;
|
||||
|
||||
while true {
|
||||
let n = fs.read(ref input, buffer)?;
|
||||
if n == 0 {
|
||||
break;
|
||||
}
|
||||
fs.write_all(ref output, slice.prefix(buffer, n))?;
|
||||
}
|
||||
|
||||
return Ok();
|
||||
}
|
||||
Reference in new issue
Block a user