nx_dump_file.nx source
↩ module page · 13 lines · 610 B
1// nx_dump_file.nx -- sovereign `cat`: print a file's bytes to stdout (no sh/3rd-party).
2// argv[1] = path. Used to inspect generated .s / artifacts from the harness.
3// license_tier: ORIGINAL
4import "nx_syscalls.nx"
5func main(argc: i64, argv: *i64) -> i64 {
6 if argc < 2 { sys_write(2, "dump: usage: nx_dump_file <path>\n" as *u8, 32); return 1 }
7 let path: *u8 = argv[1] as *u8
8 let box: *i64 = sys_mmap(16) as *i64
9 let data: *u8 = sys_read_file(path, box)
10 if (data as i64) == 0 { sys_write(2, "dump: cannot read file\n" as *u8, 23); return 2 }
11 sys_write(1, data, box[0])
12 return 0
13}