diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2020-02-07 19:01:35 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2020-02-07 19:01:35 -0800 |
commit | 177964f81055367da1b7aec8638dfc8a63ec99c5 (patch) | |
tree | 5f8711876f77c0a3d85adee02bff07344fef5b46 /share | |
parent | 52c1aef14849e0f3f4ecb4f6177c48af3b352631 (diff) | |
download | txr-177964f81055367da1b7aec8638dfc8a63ec99c5.tar.gz txr-177964f81055367da1b7aec8638dfc8a63ec99c5.tar.bz2 txr-177964f81055367da1b7aec8638dfc8a63ec99c5.zip |
file-put-buf: new argument; also, new file-place-buf
Like file-put-buf but doesn't overwrite the file.
* lisplib.c (getput_set_entries): New autoload for
file-place-buf.
* share/txr/stdlib/getput.tl (file-put-buf): New
argument for seeking into the file.
(file-place-buf): New function.
* txr.1: Documented.
Diffstat (limited to 'share')
-rw-r--r-- | share/txr/stdlib/getput.tl | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/share/txr/stdlib/getput.tl b/share/txr/stdlib/getput.tl index a50ee109..b075e812 100644 --- a/share/txr/stdlib/getput.tl +++ b/share/txr/stdlib/getput.tl @@ -84,8 +84,16 @@ (with-stream (s (open-file name "rb")) (sys:get-buf-common s bytes seek))) -(defun file-put-buf (name buf) +(defun file-put-buf (name buf : (seek 0)) (with-stream (s (open-file name "wb")) + (unless (zerop seek) + (seek-stream s seek :from-current)) + (put-buf buf 0 s))) + +(defun file-place-buf (name buf : (seek 0)) + (with-stream (s (open-file name "r+")) + (unless (zerop seek) + (seek-stream s seek :from-current)) (put-buf buf 0 s))) (defun file-append-buf (name buf) |