Hash :
172a9f5a
Author :
Thomas de Grivel
Date :
2017-05-28T13:41:21
Unix file descriptor 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)))
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
# fd-gray
Unix file descriptor 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.
### fd-gray:input-stream *fd* --> *stream*
Creates an input stream for file descriptor *fd*.
```Lisp
(let ((seq (make-array 128 '(unsigned-byte 8))))
(read-sequence seq (fd-gray:input-stream 0)))
```
### fd-gray:output-stream *fd* --> *stream*
Creates an output stream for file descriptor *fd*.
```Lisp
(let ((seq (make-array 128 '(unsigned-byte 8))))
(write-sequence seq (fd-gray:output-stream 1)))
```
### fd-gray:io-stream *fd* --> *stream*
Creates an input/output stream for file descriptor *fd*.
```Lisp
(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))
```
### fd-gray:with-input-stream (*var* *fd*) &body *body* --> *result*
Creates an input stream for file descriptor *fd* that will be closed
returning from *body*.
```Lisp
(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))
```
### fd-gray:with-output-stream (*var* *fd*) &body *body* --> *result*
Creates an output stream for file descriptor *fd* that will be closed
returning from *body*.
```Lisp
(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)))
```
### fd-gray:with-io-stream (*var* *fd*) &body *body* --> *result*
Creates an input/output stream for file descriptor *fd* that will be
closed returning from *body*.
```Lisp
(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)))
```