diff --git a/src/package.lisp b/src/package.lisp index 6159af8..c4b54b1 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -120,12 +120,13 @@ :WITH-EXECUTE* :WITH-SCP-INPUT :WITH-SCP-OUTPUT - :scp-get + :scp-get :scp-put ;; CONDITIONS & SLOTS :KNOWN-HOSTS-READING-ERROR :HOST-NOT-ALLOWED-TO-CONNECT + :SSH-UNKNOWN-HOSTKEY :+TRACE-OPTIONS+ :+DISCONNECT-CODE+ :+ERROR-CODE+ diff --git a/src/scp.lisp b/src/scp.lisp index 302ecb1..6397b8d 100644 --- a/src/scp.lisp +++ b/src/scp.lisp @@ -2,9 +2,9 @@ (in-package :libssh2) -(defun scp-get (remote-name local-name &optional (connection *ssh-connection*)) +(defmethod scp-get (remote-name (local string) &optional (connection *ssh-connection*)) (with-scp-input (in connection remote-name stat) - (with-open-file (out local-name + (with-open-file (out local :direction :output :if-exists :supersede :if-does-not-exist :create @@ -18,3 +18,16 @@ (with-scp-output (out connection remote-name (file-length in)) (cl-fad:copy-stream in out)))) + + +(defmethod scp-get (remote-name (local stream) &optional (connection *ssh-connection*)) + (when (not (output-stream-p local)) + (error 'ssh-generic-error + :code "BAD-STREAM-DIRECTION" + :message "the given stream has to support output")) + (when (not (equalp (stream-element-type local) '(unsigned-byte 8))) + (error 'ssh-generic-error + :code "BAD-STREAM-ELEMENT-TYPE" + :message "the given stream must have element type (unsigned-byte 8)")) + (with-scp-input (in connection remote-name stat) + (cl-fad:copy-stream in local)))