diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-11-17 07:30:15 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-11-17 07:30:15 -0800 |
commit | 07aba05860fa550fb72a3e3e71c95f5c87b4a337 (patch) | |
tree | 7fd4e8436fd72cfe7041d3b0d85a013e4c7082b9 | |
parent | 1d34d767c5dd5fc9d61bc9fda1a7e6a03231cd3d (diff) | |
download | txr-07aba05860fa550fb72a3e3e71c95f5c87b4a337.tar.gz txr-07aba05860fa550fb72a3e3e71c95f5c87b4a337.tar.bz2 txr-07aba05860fa550fb72a3e3e71c95f5c87b4a337.zip |
buffers: use unbuffered I/O in convenience functions.
* stdlib/getput.tl (file-get-buf, command-get-buf): If the
number of bytes to read is specified, we use an unbuffered
stream. A buffered stream can read more bytes in order to
fill a buffer, which is undesirable when dealing with a
device or pipe.
-rw-r--r-- | stdlib/getput.tl | 4 | ||||
-rw-r--r-- | txr.1 | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/stdlib/getput.tl b/stdlib/getput.tl index 4102853e..3b583d73 100644 --- a/stdlib/getput.tl +++ b/stdlib/getput.tl @@ -97,7 +97,7 @@ (put-lines lines s))) (defun file-get-buf (name : bytes (seek 0)) - (with-stream (s (open-file name "rb")) + (with-stream (s (open-file name (if bytes "rbu" "rb"))) (sys:get-buf-common s bytes seek))) (defun file-put-buf (name buf : (seek 0)) @@ -164,7 +164,7 @@ (put-lines lines s))) (defun command-get-buf (cmd : bytes (skip 0)) - (with-stream (s (open-command cmd "rb")) + (with-stream (s (open-command cmd (if bytes "rbu" "rb"))) (sys:get-buf-common s bytes skip))) (defun command-put-buf (cmd buf) @@ -27515,6 +27515,12 @@ If possible, the semantics of this parameter is achieved by performing a operation, falling back on reading and discarding bytes if the stream doesn't support seeking. +If +.meta max-bytes +is specified, then the stream is opened in unbuffered mode, so that bytes +beyond the specified range shall not be requested from the underlying file, +device or process. + .coNP Functions @, file-put-buf @ file-append-buf and @ command-put-buf .synb .mets (file-put-buf < name < buf << skip-bytes ) |