Function: tramp-file-name-with-sudo
tramp-file-name-with-sudo is a byte-compiled function defined in
tramp-cmds.el.gz.
Signature
(tramp-file-name-with-sudo FILENAME)
Documentation
Convert FILENAME into a multi-hop file name with "sudo".
An alternative method could be chosen with tramp-file-name-with-method.
Source Code
;; Defined in /usr/src/emacs/lisp/net/tramp-cmds.el.gz
(defun tramp-file-name-with-sudo (filename)
"Convert FILENAME into a multi-hop file name with \"sudo\".
An alternative method could be chosen with `tramp-file-name-with-method'."
(setq filename (expand-file-name filename))
(let ((default-method (tramp-get-file-name-with-method)))
(if (tramp-tramp-file-p filename)
(with-parsed-tramp-file-name filename nil
(cond
;; Remote file with proper method.
((string-equal method default-method)
filename)
;; Remote file on the local host.
((and
(stringp tramp-local-host-regexp) (stringp host)
(string-match-p tramp-local-host-regexp host))
(tramp-make-tramp-file-name
(make-tramp-file-name
:method default-method :localname localname)))
;; Remote file with multi-hop capable method.
((tramp-multi-hop-p v)
(tramp-make-tramp-file-name
(make-tramp-file-name
:method (tramp-find-method default-method nil host)
:user (tramp-find-user default-method nil host)
:host (tramp-find-host default-method nil host)
:localname localname :hop (tramp-make-tramp-hop-name v))))
;; Other remote file.
(t (tramp-user-error v "Multi-hop with `%s' not applicable" method))))
;; Local file.
(tramp-make-tramp-file-name
(make-tramp-file-name :method default-method :localname filename)))))