Commit 8083c2de authored by Michael Albinus's avatar Michael Albinus
Browse files

Make `tramp-make-tramp-file-name' calls consistent.

* lisp/net/tramp.el (tramp-get-buffer)
(tramp-handle-file-name-as-directory)
(tramp-handle-file-name-directory, tramp-handle-file-remote-p)
(tramp-handle-file-truename, tramp-handle-find-backup-file-name)
(tramp-handle-insert-file-contents):
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-expand-file-name)
(tramp-gvfs-get-remote-uid, tramp-gvfs-get-remote-gid)
(tramp-gvfs-maybe-open-connection):
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename)
(tramp-sh-handle-expand-file-name, )
(tramp-sh-handle-process-file, tramp-get-remote-path):
* lisp/net/tramp-smb.el (tramp-smb-handle-expand-file-name)
(tramp-smb-handle-process-file): Make `tramp-make-tramp-file-name'
calls consistent.
parent 91bf38ce
...@@ -1054,8 +1054,7 @@ file names." ...@@ -1054,8 +1054,7 @@ file names."
;; No tilde characters in file name, do normal ;; No tilde characters in file name, do normal
;; `expand-file-name' (this does "/./" and "/../"). ;; `expand-file-name' (this does "/./" and "/../").
(tramp-make-tramp-file-name (tramp-make-tramp-file-name
method user domain host port v (tramp-run-real-handler 'expand-file-name (list localname))))))
(tramp-run-real-handler 'expand-file-name (list localname))))))
(defun tramp-gvfs-get-directory-attributes (directory) (defun tramp-gvfs-get-directory-attributes (directory)
"Return GVFS attributes association list of all files in DIRECTORY." "Return GVFS attributes association list of all files in DIRECTORY."
...@@ -1885,20 +1884,15 @@ It was \"a(say)\", but has changed to \"a{sv})\"." ...@@ -1885,20 +1884,15 @@ It was \"a(say)\", but has changed to \"a{sv})\"."
"The uid of the remote connection VEC, in ID-FORMAT. "The uid of the remote connection VEC, in ID-FORMAT.
ID-FORMAT valid values are `string' and `integer'." ID-FORMAT valid values are `string' and `integer'."
(with-tramp-connection-property vec (format "uid-%s" id-format) (with-tramp-connection-property vec (format "uid-%s" id-format)
(let ((method (tramp-file-name-method vec)) (let ((user (tramp-file-name-user vec))
(user (tramp-file-name-user vec))
(domain (tramp-file-name-domain vec))
(host (tramp-file-name-host vec))
(port (tramp-file-name-port vec))
(localname (localname
(tramp-get-connection-property vec "default-location" nil))) (tramp-get-connection-property vec "default-location" nil)))
(cond (cond
((and user (equal id-format 'string)) user) ((and (equal id-format 'string) user))
(localname (localname
(tramp-compat-file-attribute-user-id (tramp-compat-file-attribute-user-id
(file-attributes (file-attributes
(tramp-make-tramp-file-name method user domain host port localname) (tramp-make-tramp-file-name vec localname) id-format)))
id-format)))
((equal id-format 'integer) tramp-unknown-id-integer) ((equal id-format 'integer) tramp-unknown-id-integer)
((equal id-format 'string) tramp-unknown-id-string))))) ((equal id-format 'string) tramp-unknown-id-string)))))
...@@ -1906,19 +1900,13 @@ ID-FORMAT valid values are `string' and `integer'." ...@@ -1906,19 +1900,13 @@ ID-FORMAT valid values are `string' and `integer'."
"The gid of the remote connection VEC, in ID-FORMAT. "The gid of the remote connection VEC, in ID-FORMAT.
ID-FORMAT valid values are `string' and `integer'." ID-FORMAT valid values are `string' and `integer'."
(with-tramp-connection-property vec (format "gid-%s" id-format) (with-tramp-connection-property vec (format "gid-%s" id-format)
(let ((method (tramp-file-name-method vec)) (let ((localname
(user (tramp-file-name-user vec))
(domain (tramp-file-name-domain vec))
(host (tramp-file-name-host vec))
(port (tramp-file-name-port vec))
(localname
(tramp-get-connection-property vec "default-location" nil))) (tramp-get-connection-property vec "default-location" nil)))
(cond (cond
(localname (localname
(tramp-compat-file-attribute-group-id (tramp-compat-file-attribute-group-id
(file-attributes (file-attributes
(tramp-make-tramp-file-name method user domain host port localname) (tramp-make-tramp-file-name vec localname) id-format)))
id-format)))
((equal id-format 'integer) tramp-unknown-id-integer) ((equal id-format 'integer) tramp-unknown-id-integer)
((equal id-format 'string) tramp-unknown-id-string))))) ((equal id-format 'string) tramp-unknown-id-string)))))
...@@ -1960,15 +1948,12 @@ connection if a previous connection has died for some reason." ...@@ -1960,15 +1948,12 @@ connection if a previous connection has died for some reason."
(set-process-query-on-exit-flag p nil))) (set-process-query-on-exit-flag p nil)))
(unless (tramp-gvfs-connection-mounted-p vec) (unless (tramp-gvfs-connection-mounted-p vec)
(let* ((method (tramp-file-name-method vec)) (let ((method (tramp-file-name-method vec))
(user (tramp-file-name-user vec)) (user (tramp-file-name-user vec))
(domain (tramp-file-name-domain vec)) (host (tramp-file-name-host vec))
(host (tramp-file-name-host vec)) (localname (tramp-file-name-unquote-localname vec))
(port (tramp-file-name-port vec)) (object-path
(localname (tramp-file-name-unquote-localname vec)) (tramp-gvfs-object-path (tramp-make-tramp-file-name vec 'noloc))))
(object-path
(tramp-gvfs-object-path
(tramp-make-tramp-file-name method user domain host port ""))))
(when (and (string-equal method "afp") (when (and (string-equal method "afp")
(string-equal localname "/")) (string-equal localname "/"))
......
...@@ -1125,7 +1125,7 @@ component is used as the target of the symlink." ...@@ -1125,7 +1125,7 @@ component is used as the target of the symlink."
'file-name-as-directory 'identity) 'file-name-as-directory 'identity)
(with-parsed-tramp-file-name (expand-file-name filename) nil (with-parsed-tramp-file-name (expand-file-name filename) nil
(tramp-make-tramp-file-name (tramp-make-tramp-file-name
method user domain host port v
(with-tramp-file-property v localname "file-truename" (with-tramp-file-property v localname "file-truename"
(let ((result nil) ; result steps in reverse order (let ((result nil) ; result steps in reverse order
(quoted (tramp-compat-file-name-quoted-p localname)) (quoted (tramp-compat-file-name-quoted-p localname))
...@@ -1177,12 +1177,13 @@ component is used as the target of the symlink." ...@@ -1177,12 +1177,13 @@ component is used as the target of the symlink."
(tramp-compat-file-attribute-type (tramp-compat-file-attribute-type
(file-attributes (file-attributes
(tramp-make-tramp-file-name (tramp-make-tramp-file-name
method user domain host port v
(mapconcat 'identity (mapconcat 'identity
(append '("") (append '("")
(reverse result) (reverse result)
(list thisstep)) (list thisstep))
"/"))))) "/")
'nohop))))
(cond ((string= "." thisstep) (cond ((string= "." thisstep)
(tramp-message v 5 "Ignoring step `.'")) (tramp-message v 5 "Ignoring step `.'"))
((string= ".." thisstep) ((string= ".." thisstep)
...@@ -1226,7 +1227,8 @@ component is used as the target of the symlink." ...@@ -1226,7 +1227,8 @@ component is used as the target of the symlink."
(let (file-name-handler-alist) (let (file-name-handler-alist)
(setq result (tramp-compat-file-name-quote result)))) (setq result (tramp-compat-file-name-quote result))))
(tramp-message v 4 "True name of `%s' is `%s'" localname result) (tramp-message v 4 "True name of `%s' is `%s'" localname result)
result)))))) result))
'nohop))))
;; Basic functions. ;; Basic functions.
...@@ -2804,11 +2806,9 @@ the result will be a local, non-Tramp, file name." ...@@ -2804,11 +2806,9 @@ the result will be a local, non-Tramp, file name."
;; be problems with UNC shares or Cygwin mounts. ;; be problems with UNC shares or Cygwin mounts.
(let ((default-directory (tramp-compat-temporary-file-directory))) (let ((default-directory (tramp-compat-temporary-file-directory)))
(tramp-make-tramp-file-name (tramp-make-tramp-file-name
method user domain host port v (tramp-drop-volume-letter
(tramp-drop-volume-letter (tramp-run-real-handler
(tramp-run-real-handler 'expand-file-name (list localname))))))))
'expand-file-name (list localname)))
hop)))))
;;; Remote commands: ;;; Remote commands:
...@@ -2997,8 +2997,7 @@ the result will be a local, non-Tramp, file name." ...@@ -2997,8 +2997,7 @@ the result will be a local, non-Tramp, file name."
(setq input (with-parsed-tramp-file-name infile nil localname)) (setq input (with-parsed-tramp-file-name infile nil localname))
;; INFILE must be copied to remote host. ;; INFILE must be copied to remote host.
(setq input (tramp-make-tramp-temp-file v) (setq input (tramp-make-tramp-temp-file v)
tmpinput tmpinput (tramp-make-tramp-file-name v input 'nohop))
(tramp-make-tramp-file-name method user domain host port input))
(copy-file infile tmpinput t))) (copy-file infile tmpinput t)))
(when input (setq command (format "%s <%s" command input))) (when input (setq command (format "%s <%s" command input)))
...@@ -3031,8 +3030,7 @@ the result will be a local, non-Tramp, file name." ...@@ -3031,8 +3030,7 @@ the result will be a local, non-Tramp, file name."
;; stderr must be copied to remote host. The temporary ;; stderr must be copied to remote host. The temporary
;; file must be deleted after execution. ;; file must be deleted after execution.
(setq stderr (tramp-make-tramp-temp-file v) (setq stderr (tramp-make-tramp-temp-file v)
tmpstderr (tramp-make-tramp-file-name tmpstderr (tramp-make-tramp-file-name v stderr 'nohop))))
method user domain host port stderr))))
;; stderr to be discarded. ;; stderr to be discarded.
((null (cadr destination)) ((null (cadr destination))
(setq stderr "/dev/null")))) (setq stderr "/dev/null"))))
...@@ -5294,7 +5292,7 @@ Nonexistent directories are removed from spec." ...@@ -5294,7 +5292,7 @@ Nonexistent directories are removed from spec."
(lambda (x) (lambda (x)
(and (and
(stringp x) (stringp x)
(file-directory-p (tramp-make-tramp-file-name vec x)) (file-directory-p (tramp-make-tramp-file-name vec x 'nohop))
x)) x))
remote-path))))) remote-path)))))
......
...@@ -715,8 +715,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." ...@@ -715,8 +715,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
;; No tilde characters in file name, do normal ;; No tilde characters in file name, do normal
;; `expand-file-name' (this does "/./" and "/../"). ;; `expand-file-name' (this does "/./" and "/../").
(tramp-make-tramp-file-name (tramp-make-tramp-file-name
method user domain host port v (tramp-run-real-handler 'expand-file-name (list localname))))))
(tramp-run-real-handler 'expand-file-name (list localname))))))
(defun tramp-smb-action-get-acl (proc vec) (defun tramp-smb-action-get-acl (proc vec)
"Read ACL data from connection buffer." "Read ACL data from connection buffer."
...@@ -1235,8 +1234,7 @@ component is used as the target of the symlink." ...@@ -1235,8 +1234,7 @@ component is used as the target of the symlink."
(setq input (with-parsed-tramp-file-name infile nil localname)) (setq input (with-parsed-tramp-file-name infile nil localname))
;; INFILE must be copied to remote host. ;; INFILE must be copied to remote host.
(setq input (tramp-make-tramp-temp-file v) (setq input (tramp-make-tramp-temp-file v)
tmpinput tmpinput (tramp-make-tramp-file-name v input))
(tramp-make-tramp-file-name method user domain host port input))
(copy-file infile tmpinput t)) (copy-file infile tmpinput t))
;; Transform input into a filename powershell does understand. ;; Transform input into a filename powershell does understand.
(setq input (format "//%s%s" host input))) (setq input (format "//%s%s" host input)))
......
...@@ -1462,7 +1462,7 @@ necessary only. This function will be used in file name completion." ...@@ -1462,7 +1462,7 @@ necessary only. This function will be used in file name completion."
vec "process-buffer" vec "process-buffer"
(tramp-get-connection-property vec "process-buffer" nil)) (tramp-get-connection-property vec "process-buffer" nil))
(setq buffer-undo-list t (setq buffer-undo-list t
default-directory (tramp-make-tramp-file-name vec "/" 'nohop)) default-directory (tramp-make-tramp-file-name vec 'noloc 'nohop))
(current-buffer)))) (current-buffer))))
(defun tramp-get-connection-buffer (vec) (defun tramp-get-connection-buffer (vec)
...@@ -3072,11 +3072,11 @@ User is always nil." ...@@ -3072,11 +3072,11 @@ User is always nil."
;; Run the command on the localname portion only unless we are in ;; Run the command on the localname portion only unless we are in
;; completion mode. ;; completion mode.
(tramp-make-tramp-file-name (tramp-make-tramp-file-name
v (unless (and (zerop (length (tramp-file-name-localname v))) v (or (and (zerop (length (tramp-file-name-localname v)))
(not (tramp-connectable-p file))) (not (tramp-connectable-p file)))
(tramp-run-real-handler (tramp-run-real-handler
'file-name-as-directory 'file-name-as-directory
(list (or (tramp-file-name-localname v) ""))))))) (list (tramp-file-name-localname v)))))))
(defun tramp-handle-file-name-case-insensitive-p (filename) (defun tramp-handle-file-name-case-insensitive-p (filename)
"Like `file-name-case-insensitive-p' for Tramp files." "Like `file-name-case-insensitive-p' for Tramp files."
...@@ -3153,11 +3153,16 @@ User is always nil." ...@@ -3153,11 +3153,16 @@ User is always nil."
(defun tramp-handle-file-name-directory (file) (defun tramp-handle-file-name-directory (file)
"Like `file-name-directory' but aware of Tramp files." "Like `file-name-directory' but aware of Tramp files."
(with-parsed-tramp-file-name file nil ;; Everything except the last filename thing is the directory. We
(setf (tramp-file-name-localname v) nil) ;; cannot apply `with-parsed-tramp-file-name', because this expands
;; Run the command on the localname portion only. ;; the remote file name parts.
(let ((v (tramp-dissect-file-name file t)))
;; Run the command on the localname portion only. If this returns
;; nil, mark also the localname part of `v' as nil.
(tramp-make-tramp-file-name (tramp-make-tramp-file-name
v (tramp-run-real-handler'file-name-directory (list localname))))) v (or (tramp-run-real-handler
'file-name-directory (list (tramp-file-name-localname v)))
'noloc))))
(defun tramp-handle-file-name-nondirectory (file) (defun tramp-handle-file-name-nondirectory (file)
"Like `file-name-nondirectory' but aware of Tramp files." "Like `file-name-nondirectory' but aware of Tramp files."
...@@ -3202,8 +3207,7 @@ User is always nil." ...@@ -3202,8 +3207,7 @@ User is always nil."
((eq identification 'host) (tramp-file-name-host-port v)) ((eq identification 'host) (tramp-file-name-host-port v))
((eq identification 'localname) localname) ((eq identification 'localname) localname)
((eq identification 'hop) hop) ((eq identification 'hop) hop)
(t (tramp-make-tramp-file-name (t (tramp-make-tramp-file-name v 'noloc)))))))))
method user domain host port "" hop)))))))))
(defun tramp-handle-file-selinux-context (_filename) (defun tramp-handle-file-selinux-context (_filename)
"Like `file-selinux-context' for Tramp files." "Like `file-selinux-context' for Tramp files."
...@@ -3237,7 +3241,7 @@ User is always nil." ...@@ -3237,7 +3241,7 @@ User is always nil."
result result
(with-parsed-tramp-file-name (expand-file-name result) v2 (with-parsed-tramp-file-name (expand-file-name result) v2
(tramp-make-tramp-file-name (tramp-make-tramp-file-name
v2-method v2-user v2-domain v2-host v2-port v2
(funcall (funcall
(if (tramp-compat-file-name-quoted-p v2-localname) (if (tramp-compat-file-name-quoted-p v2-localname)
'tramp-compat-file-name-quote 'identity) 'tramp-compat-file-name-quote 'identity)
...@@ -3248,7 +3252,8 @@ User is always nil." ...@@ -3248,7 +3252,8 @@ User is always nil."
(tramp-compat-file-name-quote symlink-target)) (tramp-compat-file-name-quote symlink-target))
(expand-file-name (expand-file-name
symlink-target (file-name-directory v2-localname))) symlink-target (file-name-directory v2-localname)))
v2-localname))))) v2-localname))
'nohop)))
(when (>= numchase numchase-limit) (when (>= numchase numchase-limit)
(tramp-error (tramp-error
v1 'file-error v1 'file-error
...@@ -3267,8 +3272,7 @@ User is always nil." ...@@ -3267,8 +3272,7 @@ User is always nil."
(if (and (stringp (cdr x)) (if (and (stringp (cdr x))
(file-name-absolute-p (cdr x)) (file-name-absolute-p (cdr x))
(not (tramp-tramp-file-p (cdr x)))) (not (tramp-tramp-file-p (cdr x))))
(tramp-make-tramp-file-name (tramp-make-tramp-file-name v (cdr x))
method user domain host port (cdr x) hop)
(cdr x)))) (cdr x))))
tramp-backup-directory-alist) tramp-backup-directory-alist)
backup-directory-alist))) backup-directory-alist)))
...@@ -3373,7 +3377,7 @@ User is always nil." ...@@ -3373,7 +3377,7 @@ User is always nil."
((stringp remote-copy) ((stringp remote-copy)
(file-local-copy (file-local-copy
(tramp-make-tramp-file-name (tramp-make-tramp-file-name
method user domain host port remote-copy))) v remote-copy 'nohop)))
((stringp tramp-temp-buffer-file-name) ((stringp tramp-temp-buffer-file-name)
(copy-file (copy-file
filename tramp-temp-buffer-file-name 'ok) filename tramp-temp-buffer-file-name 'ok)
...@@ -3417,9 +3421,7 @@ User is always nil." ...@@ -3417,9 +3421,7 @@ User is always nil."
(or remote-copy (null tramp-temp-buffer-file-name))) (or remote-copy (null tramp-temp-buffer-file-name)))
(delete-file local-copy)) (delete-file local-copy))
(when (stringp remote-copy) (when (stringp remote-copy)
(delete-file (delete-file (tramp-make-tramp-file-name v remote-copy 'nohop)))))
(tramp-make-tramp-file-name
method user domain host port remote-copy)))))
;; Result. ;; Result.
(list (expand-file-name filename) (list (expand-file-name filename)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment