diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-06-29 06:29:12 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-06-29 06:29:12 -0700 |
commit | f1f41419f964a4c7010b0ad3ec68f0d21fe6f81d (patch) | |
tree | 7b01988d1041cac59c9b028098d69d9271c0fd36 /stdlib | |
parent | e9e2e3eab9fa5fae02f7f82b56e43ddb162fc7e8 (diff) | |
download | txr-f1f41419f964a4c7010b0ad3ec68f0d21fe6f81d.tar.gz txr-f1f41419f964a4c7010b0ad3ec68f0d21fe6f81d.tar.bz2 txr-f1f41419f964a4c7010b0ad3ec68f0d21fe6f81d.zip |
Add mode-opt to all I/O convenience functions.
* stdlib/getput.tl (command-get, command-put, command-get-string,
command-put-string, command-get-lines, command-put-lines,
command-put-buf, command-get-json, command-put-json,
command-get-jsons, command-put-jsons): Add mopt parameter,
which is interpolated into appropriate mode string.
This allows "z" to be used for gzip compression.
* txr.1: Updated Syntax synopses.
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/getput.tl | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/stdlib/getput.tl b/stdlib/getput.tl index e90f3b28..0cf751a1 100644 --- a/stdlib/getput.tl +++ b/stdlib/getput.tl @@ -141,49 +141,49 @@ (with-stream (s (open-file name `a@mopt`)) (put-jsons s seq flat-p))) -(defun command-get (cmd) - (with-stream (s (open-command cmd)) +(defun command-get (cmd : mopt) + (with-stream (s (open-command cmd `r@mopt`)) (read s))) -(defun command-put (cmd obj) - (with-stream (s (open-command cmd "w")) +(defun command-put (cmd obj : mopt) + (with-stream (s (open-command cmd `w@mopt`)) (prinl obj s))) -(defun command-get-string (cmd) - (with-stream (s (open-command cmd)) +(defun command-get-string (cmd : mopt) + (with-stream (s (open-command cmd `r@mopt`)) (get-string s))) -(defun command-put-string (cmd string) - (with-stream (s (open-command cmd "w")) +(defun command-put-string (cmd string : mopt) + (with-stream (s (open-command cmd `w@mopt`)) (put-string string s))) -(defun command-get-lines (cmd) - (get-lines (open-command cmd))) +(defun command-get-lines (cmd : mopt) + (get-lines (open-command cmd `r@mopt`))) -(defun command-put-lines (cmd lines) - (with-stream (s (open-command cmd "w")) +(defun command-put-lines (cmd lines : mopt) + (with-stream (s (open-command cmd `w@mopt`)) (put-lines lines s))) (defun command-get-buf (cmd : bytes (skip 0)) (with-stream (s (open-command cmd (if bytes "rbu" "rb"))) (sys:get-buf-common s bytes skip))) -(defun command-put-buf (cmd buf) - (with-stream (s (open-command cmd "wb")) +(defun command-put-buf (cmd buf : mopt) + (with-stream (s (open-command cmd `wb@mopt`)) (put-buf buf 0 s))) -(defun command-get-json (cmd) - (with-stream (s (open-command cmd)) +(defun command-get-json (cmd : mopt) + (with-stream (s (open-command cmd `r@mopt`)) (get-json s))) -(defun command-put-json (cmd obj : flat-p) - (with-stream (s (open-command cmd "w")) +(defun command-put-json (cmd obj : flat-p mopt) + (with-stream (s (open-command cmd `w@mopt`)) (put-jsonl obj s flat-p))) -(defun command-get-jsons (cmd) - (with-stream (s (open-command cmd)) +(defun command-get-jsons (cmd : mopt) + (with-stream (s (open-command cmd `r@mopt`)) (get-jsons s))) -(defun command-put-jsons (cmd seq : flat-p) - (with-stream (s (open-command cmd "w")) +(defun command-put-jsons (cmd seq : flat-p mopt) + (with-stream (s (open-command cmd `w@mopt`)) (put-jsons seq s flat-p))) |