Function: tramp-smb-get-localname

tramp-smb-get-localname is a byte-compiled function defined in tramp-smb.el.gz.

Signature

(tramp-smb-get-localname VEC &optional SHARE)

Documentation

Return the file name of LOCALNAME.

If SHARE is non-nil, include the share name. If VEC has no cifs capabilities, exchange "/" by "\\\\".

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-smb.el.gz
(defun tramp-smb-get-localname (vec &optional share)
  "Return the file name of LOCALNAME.
If SHARE is non-nil, include the share name.
If VEC has no cifs capabilities, exchange \"/\" by \"\\\\\"."
  (save-match-data
    (let ((localname (tramp-file-name-unquote-localname vec)))
      (unless share
	(setq
	 localname
	 (if (string-match
	      (rx bol (? "/") (+ (not "/")) (group "/" (* nonl))) localname)
	     ;; There is a share, separated by "/".
	     (if (not (tramp-smb-get-cifs-capabilities vec))
		 (mapconcat
		  (lambda (x) (if (equal x ?/) "\\" (char-to-string x)))
		  (match-string 1 localname) "")
	       (match-string 1 localname))
	   ;; There is just a share.
	   (if (string-match
		(rx bol (? "/") (group (+ (not "/"))) eol) localname)
	       (match-string 1 localname)
	     ""))))

      ;; Sometimes we have discarded `substitute-in-file-name'.
      (when (string-match (rx (group "$$") (| "/" eol)) localname)
	(setq localname (replace-match "$" nil nil localname 1)))

      ;; A trailing space is not supported.
      (when (string-match-p (rx blank eol) localname)
	(tramp-error
	 vec 'file-error
	 "Invalid file name %s" (tramp-make-tramp-file-name vec localname)))

      localname)))