Function: tramp-make-copy-program-file-name

tramp-make-copy-program-file-name is a byte-compiled function defined in tramp-sh.el.gz.

Signature

(tramp-make-copy-program-file-name VEC)

Documentation

Create a file name suitable for scp, pscp, or nc and workalikes.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-sh.el.gz
(defun tramp-make-copy-program-file-name (vec)
  "Create a file name suitable for `scp', `pscp', or `nc' and workalikes."
  (let ((method (tramp-file-name-method vec))
	(user (tramp-file-name-user vec))
	(host (tramp-file-name-host vec))
	(localname
	 (directory-file-name (tramp-file-name-unquote-localname vec))))
    (when (string-match-p tramp-ipv6-regexp host)
      (setq host (format "[%s]" host)))
    ;; This does not work for MS Windows scp, if there are characters
    ;; to be quoted.  OpenSSH 8 supports disabling of strict file name
    ;; checking in scp, we use it when available.
    (unless (string-match-p "ftp$" method)
      (setq localname (tramp-unquote-shell-quote-argument localname)))
    (cond
     ((tramp-get-method-parameter vec 'tramp-remote-copy-program)
      localname)
     ((zerop (length user)) (format "%s:%s" host localname))
     (t (format "%s@%s:%s" user host localname)))))