diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-02-20 15:07:08 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-02-20 15:07:08 -0700 |
commit | 4e5a36d3c78aaeb6ece87403744410e8b34dcd71 (patch) | |
tree | cfc8ebbfb55833cd5fb5a020e30904cd624025c6 /src/connection/local.lisp | |
parent | b868e01ce93bb9f89b27633ae1a3e3dc59ecef5f (diff) | |
download | consfigurator-4e5a36d3c78aaeb6ece87403744410e8b34dcd71.tar.gz |
extend CONNECTION-WRITEFILE and CONNECTION-RUN APIs for stream input
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/connection/local.lisp')
-rw-r--r-- | src/connection/local.lisp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/connection/local.lisp b/src/connection/local.lisp index 65dc0bd..e56ffd2 100644 --- a/src/connection/local.lisp +++ b/src/connection/local.lisp @@ -33,8 +33,10 @@ root Lisp is running on, as the root Lisp's uid.")) (multiple-value-bind (output _ exit-code) (run-program shell-cmd :force-shell t - :input (and input - (make-string-input-stream input)) + :input (typecase input + (stream input) + (string (make-string-input-stream input)) + (t nil)) :output :string :error-output :output :ignore-error-status t) @@ -44,10 +46,18 @@ root Lisp is running on, as the root Lisp's uid.")) (defmethod connection-readfile ((connection local-connection) path) (read-file-string path)) -(defmethod connection-writefile ((connection local-connection) path contents) +(defmethod connection-writefile ((connection local-connection) + path + (contents string)) (with-open-file (stream path :direction :output :if-exists :supersede) (write-string contents stream))) +(defmethod connection-writefile ((connection local-connection) + path + (contents stream)) + (with-open-file (stream path :direction :output :if-exists :supersede) + (copy-stream-to-stream contents stream))) + (defmethod connection-upload ((connection local-connection) from to) (copy-file from to)) |