From f1f41419f964a4c7010b0ad3ec68f0d21fe6f81d Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 29 Jun 2022 06:29:12 -0700 Subject: 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. --- stdlib/getput.tl | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'stdlib') 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))) -- cgit v1.2.3