Implementation
- Primitive file operations talks to libc directly.
- Rust's
std
crate doesn't expose some underlying details.
Opening files
(define (open-file path output)
(let ((descriptor ($$open-file (string->path path) output)))
(unless descriptor
(error "cannot open file"))
(make-port
(lambda () ($$read-file descriptor))
(lambda (byte) ($$write-file descriptor byte))
(lambda () ($$close-file descriptor)))))