041-fileio.scm (474B)
1 ; Round-trip the prelude port API (open-input/read-bytes/close) on this 2 ; very file. The first byte is `;` (ASCII 59) -- we exit with that, 3 ; proving open and read both succeeded and the data made it into a 4 ; Scheme bytevector. Path comes from (argv); no raw sys-* primitives. 5 (define ip (open-input (car (cdr (argv))))) 6 (if (not (car ip)) (exit 1) 0) 7 (define rd (read-bytes (cdr ip) 1)) 8 (close (cdr ip)) 9 (if (not (car rd)) (exit 2) 0) 10 (exit (bytevector-u8-ref (cdr rd) 0))