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 | |
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.
-rw-r--r-- | stdlib/getput.tl | 44 | ||||
-rw-r--r-- | txr.1 | 22 |
2 files changed, 33 insertions, 33 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))) @@ -62805,9 +62805,9 @@ the file is extended by appending the new data to its end. .coNP Functions @, command-get @ command-get-string and @ command-get-lines .synb -.mets (command-get << cmd ) -.mets (command-get-string << cmd ) -.mets (command-get-lines << cmd ) +.mets (command-get < cmd <> [ mode-opts ]) +.mets (command-get-string < cmd <> [ mode-opts ]) +.mets (command-get-lines < cmd <> [ mode-opts ]) .syne .desc The @@ -62841,9 +62841,9 @@ list is consumed to the end, as indicated in the description of .coNP Functions @, command-put @ command-put-string and @ command-put-lines .synb -.mets (command-put < cmd << obj ) -.mets (command-put-string < cmd << string ) -.mets (command-put-lines < cmd << list ) +.mets (command-put < cmd < obj <> [ mode-opts ]) +.mets (command-put-string < cmd < string <> [ mode-opts ]) +.mets (command-put-lines < cmd < list <> [ mode-opts ]) .syne .desc The @@ -62887,7 +62887,7 @@ to the stream using the function. The return value is that of .codn put-lines . -.SS* Buffer streams +.<SS* Buffer streams A stream type exists which allows .code buf objects to be manipulated through the stream interface. @@ -79258,8 +79258,8 @@ in order to append data to the target file rather than overwrite it. .coNP Functions @ command-get-json and @ command-get-jsons .synb -.mets (command-get-json << cmd ) -.mets (command-get-jsons << cmd ) +.mets (command-get-json < cmd <> [ mode-opts ]) +.mets (command-get-jsons < cmd <> [ mode-opts ]) .syne .desc The @@ -79287,8 +79287,8 @@ on the stream, and returns the value returned by that function. .coNP Functions @ command-put-json and @ command-put-jsons .synb -.mets (command-put-json < cmd < obj <> [ flat-p ]) -.mets (command-put-jsons < cmd < seq <> [ flat-p ]) +.mets (command-put-json < cmd < obj >> [ flat-p <> [ mode-opts ]]) +.mets (command-put-jsons < cmd < seq >> [ flat-p <> [ mode-opts ]]) .syne .desc The |