Branch
Hash :
90c9c090
Author :
Thomas de Grivel
Date :
2017-05-28T14:20:42
fd-flexi streams are flexi streams using fd-gray streams to embed Unix file descriptors in standard Common Lisp streams supporting dynamic external encoding.
Creates an input flexi stream for file descriptor fd, initially using external-format encoding.
(read-line (fd-flexi:input-stream 0))
Creates an output flexi stream for file descriptor fd, initially using external-format encoding.
(write-string "Hello world !" (fd-flexi:output-stream 1))
Creates an input/output flexi stream for file descriptor fd, initially using external-format encoding.
(let ((stream (fd-flexi:io-stream (fcntl:open "file.txt" fcntl:+o-rdwr+))))
(write-string (read-line stream) stream))
Creates an input flexi stream for file descriptor fd, initially using external-format encoding, that will be closed returning from body.
(fd-flexi:with-input-stream (in (fcntl:open "file.txt" fcntl:+o-rdonly+))
(read-line in))
Creates an output flexi stream for file descriptor fd, initially using external-format encoding, that will be closed returning from body.
(fd-flexi:with-output-stream (out (fcntl:open "file.txt" fcntl:+o-wronly+))
(write-string "Hello world !" out))
Creates an input/output flexi stream for file descriptor fd, initially using external-format encoding, that will be closed returning from body.
(fd-flexi:with-io-stream (out (fcntl:open "file.txt" fcntl:+o-rdwr+))
(write-string (read-line stream) stream))
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
# fd-flexi
fd-flexi streams are flexi streams using fd-gray streams to embed
Unix file descriptors in standard Common Lisp streams supporting
dynamic external encoding.
### fd-flexi:input-stream *fd* &optional (*external-format* :utf-8) --> *stream*
Creates an input flexi stream for file descriptor *fd*, initially using
*external-format* encoding.
```Lisp
(read-line (fd-flexi:input-stream 0))
```
### fd-flexi:output-stream *fd* &optional (*external-format* :utf-8) --> *stream*
Creates an output flexi stream for file descriptor *fd*, initially using
*external-format* encoding.
```Lisp
(write-string "Hello world !" (fd-flexi:output-stream 1))
```
### fd-flexi:io-stream *fd* &optional (*external-format* :utf-8) --> *stream*
Creates an input/output flexi stream for file descriptor *fd*, initially
using *external-format* encoding.
```Lisp
(let ((stream (fd-flexi:io-stream (fcntl:open "file.txt" fcntl:+o-rdwr+))))
(write-string (read-line stream) stream))
```
### fd-flexi:with-input-stream (*var* *fd* &optional (*external-format* :utf-8)) &body *body* --> *result*
Creates an input flexi stream for file descriptor *fd*, initially
using *external-format* encoding, that will be closed returning
from *body*.
```Lisp
(fd-flexi:with-input-stream (in (fcntl:open "file.txt" fcntl:+o-rdonly+))
(read-line in))
```
### fd-flexi:with-output-stream (*var* *fd* &optional (*external-format* :utf-8)) &body *body* --> *result*
Creates an output flexi stream for file descriptor *fd*, initially
using *external-format* encoding, that will be closed returning from
*body*.
```Lisp
(fd-flexi:with-output-stream (out (fcntl:open "file.txt" fcntl:+o-wronly+))
(write-string "Hello world !" out))
```
### fd-flexi:with-io-stream (*var* *fd*) &body *body* --> *result*
Creates an input/output flexi stream for file descriptor *fd*, initially
using *external-format* encoding, that will be closed returning from
*body*.
```Lisp
(fd-flexi:with-io-stream (out (fcntl:open "file.txt" fcntl:+o-rdwr+))
(write-string (read-line stream) stream))
```