Function: tramp-smb-handle-expand-file-name
tramp-smb-handle-expand-file-name is a byte-compiled function defined
in tramp-smb.el.gz.
Signature
(tramp-smb-handle-expand-file-name NAME &optional DIR)
Documentation
Like expand-file-name for Tramp files.
Source Code
;; Defined in /usr/src/emacs/lisp/net/tramp-smb.el.gz
(defun tramp-smb-handle-expand-file-name (name &optional dir)
"Like `expand-file-name' for Tramp files."
;; If DIR is not given, use DEFAULT-DIRECTORY or "/".
(setq dir (or dir default-directory "/"))
;; Handle empty NAME.
(when (zerop (length name)) (setq name "."))
;; Unless NAME is absolute, concat DIR and NAME.
(unless (file-name-absolute-p name)
(setq name (tramp-compat-file-name-concat dir name)))
;; If NAME is not a Tramp file, run the real handler.
(if (not (tramp-tramp-file-p name))
(tramp-run-real-handler #'expand-file-name (list name nil))
;; Dissect NAME.
(with-parsed-tramp-file-name name nil
;; Tilde expansion if necessary. We use the user name as share,
;; which is often the case in domains.
(when (string-match "\\`/?~\\([^/]*\\)" localname)
(setq localname
(replace-match
(if (zerop (length (match-string 1 localname)))
user
(match-string 1 localname))
nil nil localname)))
;; Make the file name absolute.
(unless (tramp-run-real-handler #'file-name-absolute-p (list localname))
(setq localname (concat "/" localname)))
;; Do not keep "/..".
(when (string-match-p "^/\\.\\.?$" localname)
(setq localname "/"))
;; No tilde characters in file name, do normal
;; `expand-file-name' (this does "/./" and "/../").
(tramp-make-tramp-file-name
v (tramp-run-real-handler #'expand-file-name (list localname))))))