summaryrefslogtreecommitdiffstats
path: root/stdlib/copy-file.tl
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-02-13 12:38:33 -0800
committerKaz Kylheku <kaz@kylheku.com>2022-02-13 12:38:33 -0800
commit9da084f7a68d81cb204654c37ad7e7c0e2d82c20 (patch)
treebcd2bc31ee8c70a9887a5f130323a8b9b38d67dd /stdlib/copy-file.tl
parent6221390e43375c054a2d556edfbfb4af44ea2361 (diff)
downloadtxr-9da084f7a68d81cb204654c37ad7e7c0e2d82c20.tar.gz
txr-9da084f7a68d81cb204654c37ad7e7c0e2d82c20.tar.bz2
txr-9da084f7a68d81cb204654c37ad7e7c0e2d82c20.zip
New function: cat-files.
* lisplib.c (copy_file_instantiate): Trigger autoload on cat-files. * stdlib/copy-file.tl (cat-files): New function. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
Diffstat (limited to 'stdlib/copy-file.tl')
-rw-r--r--stdlib/copy-file.tl13
1 files changed, 13 insertions, 0 deletions
diff --git a/stdlib/copy-file.tl b/stdlib/copy-file.tl
index 50408aca..beab2fbc 100644
--- a/stdlib/copy-file.tl
+++ b/stdlib/copy-file.tl
@@ -87,6 +87,19 @@
(skip `skip copying @path` (exc . args) (return))
(retry `retry copying @path` (exc . args))))))
+(defun cat-files (to-path . from-paths)
+ (let ((buf (make-buf copy-size)))
+ (with-stream (ost (open-file to-path "wb"))
+ (each ((from-path from-paths))
+ (with-stream (ist (open-file from-path "b"))
+ (while (eql (len buf) copy-size)
+ (fill-buf-adjust buf 0 ist)
+ (put-buf buf 0 ost)))
+ (buf-set-length buf copy-size)))
+ (buf-set-length buf 0)
+ (buf-trim buf)
+ nil))
+
(defun do-tweak-obj (to-path st opts link-p)
(when (and opts.perms (not link-p))
(chmod to-path st.mode))