Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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+
Expand Down
17 changes: 15 additions & 2 deletions src/scp.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)))