Branch
Hash :
7606d092
Author :
Thomas de Grivel
Date :
2017-06-20T22:55:45
fd-gray streams are binary gray streams operating on
(unsigned-byte 8)
data using unistd:read
, unistd:write
and
unistd:close
to embed Unix file descriptors in standard Common Lisp
streams.
Creates an input stream for file descriptor fd.
(let ((seq (make-array 128 '(unsigned-byte 8))))
(read-sequence seq (fd-gray:input-stream 0)))
Creates an output stream for file descriptor fd.
(let ((seq (make-array 128 '(unsigned-byte 8))))
(write-sequence seq (fd-gray:output-stream 1)))
Creates an input/output stream for file descriptor fd.
(let ((seq (make-array 128 '(unsigned-byte 8))
(stream (fd-gray:io-stream (fcntl:open "file.bin" fcntl:+o-rdwr+))))
(read-sequence seq stream)
(write-sequence seq stream))
Creates an input stream for file descriptor fd that will be closed returning from body.
(fd-gray:with-input-stream (in (fcntl:open "file.bin" fcntl:+o-rdonly+))
(let ((seq (make-array 128 '(unsigned-byte 8))))
(read-sequence seq in)
seq))
Creates an output stream for file descriptor fd that will be closed returning from body.
(let ((seq (make-array 128 '(unsigned-byte 8))))
(fd-gray:with-output-stream (out (fcntl:open "file.bin" fcntl:+o-wronly+))
(write-sequence seq out)))
Creates an input/output stream for file descriptor fd that will be closed returning from body.
(fd-gray:with-io-stream (out (fcntl:open "file.bin" fcntl:+o-rdwr+))
(let ((seq (make-array 128 '(unsigned-byte 8))))
(read-sequence seq out)
(write-sequence seq out)))