Commit b86c1cd8 authored by Michael Albinus's avatar Michael Albinus
Browse files

* net/tramp.el (tramp-default-file-modes) New defun. Replace all

calls of `file-modes' by this.
(tramp-handle-find-backup-file-name): Use `symbol-value' instead
of `boundp'.
parent c42e03b4
...@@ -2763,6 +2763,12 @@ and gid of the corresponding user is taken. Both parameters must be integers." ...@@ -2763,6 +2763,12 @@ and gid of the corresponding user is taken. Both parameters must be integers."
(when (file-exists-p truename) (when (file-exists-p truename)
(tramp-mode-string-to-int (nth 8 (file-attributes truename)))))) (tramp-mode-string-to-int (nth 8 (file-attributes truename))))))
(defun tramp-default-file-modes (filename)
"Return file modes of FILENAME as integer.
If the file modes of FILENAME cannot be determined, return the
value of `default-file-modes'."
(or (file-modes filename) (default-file-modes)))
(defun tramp-handle-file-directory-p (filename) (defun tramp-handle-file-directory-p (filename)
"Like `file-directory-p' for Tramp files." "Like `file-directory-p' for Tramp files."
;; Care must be taken that this function returns `t' for symlinks ;; Care must be taken that this function returns `t' for symlinks
...@@ -3177,7 +3183,7 @@ KEEP-DATE is non-nil if NEWNAME should have the same timestamp as FILENAME." ...@@ -3177,7 +3183,7 @@ KEEP-DATE is non-nil if NEWNAME should have the same timestamp as FILENAME."
;; KEEP-DATE handling. ;; KEEP-DATE handling.
(when keep-date (set-file-times newname (nth 5 (file-attributes filename)))) (when keep-date (set-file-times newname (nth 5 (file-attributes filename))))
;; Set the mode. ;; Set the mode.
(set-file-modes newname (file-modes filename)) (set-file-modes newname (tramp-default-file-modes filename))
;; If the operation was `rename', delete the original file. ;; If the operation was `rename', delete the original file.
(unless (eq op 'copy) (delete-file filename))) (unless (eq op 'copy) (delete-file filename)))
...@@ -3314,7 +3320,7 @@ the uid and gid from FILENAME." ...@@ -3314,7 +3320,7 @@ the uid and gid from FILENAME."
(condition-case nil (condition-case nil
(when (and keep-date (not preserve-uid-gid)) (when (and keep-date (not preserve-uid-gid))
(set-file-times newname (nth 5 (file-attributes filename))) (set-file-times newname (nth 5 (file-attributes filename)))
(set-file-modes newname (file-modes filename))) (set-file-modes newname (tramp-default-file-modes filename)))
(error))))) (error)))))
(defun tramp-do-copy-or-rename-file-out-of-band (op filename newname keep-date) (defun tramp-do-copy-or-rename-file-out-of-band (op filename newname keep-date)
...@@ -3414,7 +3420,7 @@ be a local filename. The method used must be an out-of-band method." ...@@ -3414,7 +3420,7 @@ be a local filename. The method used must be an out-of-band method."
;; Set the mode. ;; Set the mode.
(unless (and keep-date copy-keep-date) (unless (and keep-date copy-keep-date)
(set-file-modes newname (file-modes filename)))) (set-file-modes newname (tramp-default-file-modes filename))))
;; If the operation was `rename', delete the original file. ;; If the operation was `rename', delete the original file.
(unless (eq op 'copy) (unless (eq op 'copy)
...@@ -4072,7 +4078,7 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1." ...@@ -4072,7 +4078,7 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1."
(tramp-message v 5 "Decoding remote file %s...done" filename) (tramp-message v 5 "Decoding remote file %s...done" filename)
;; Set proper permissions. ;; Set proper permissions.
(set-file-modes tmpfile (file-modes filename)) (set-file-modes tmpfile (tramp-default-file-modes filename))
;; Set local user ownership. ;; Set local user ownership.
(tramp-set-file-uid-gid tmpfile))) (tramp-set-file-uid-gid tmpfile)))
...@@ -4210,7 +4216,7 @@ coding system might not be determined. This function repairs it." ...@@ -4210,7 +4216,7 @@ coding system might not be determined. This function repairs it."
(let ((backup-directory-alist (let ((backup-directory-alist
;; Emacs case ;; Emacs case
(when (boundp 'backup-directory-alist) (when (boundp 'backup-directory-alist)
(if (boundp 'tramp-backup-directory-alist) (if (symbol-value 'tramp-backup-directory-alist)
(mapcar (mapcar
'(lambda (x) '(lambda (x)
(cons (cons
...@@ -4226,7 +4232,7 @@ coding system might not be determined. This function repairs it." ...@@ -4226,7 +4232,7 @@ coding system might not be determined. This function repairs it."
(bkup-backup-directory-info (bkup-backup-directory-info
;; XEmacs case ;; XEmacs case
(when (boundp 'bkup-backup-directory-info) (when (boundp 'bkup-backup-directory-info)
(if (boundp 'tramp-bkup-backup-directory-info) (if (symbol-value 'tramp-bkup-backup-directory-info)
(mapcar (mapcar
'(lambda (x) '(lambda (x)
(nconc (nconc
...@@ -4333,7 +4339,7 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file." ...@@ -4333,7 +4339,7 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
(let ((rem-dec (tramp-get-remote-coding v "remote-decoding")) (let ((rem-dec (tramp-get-remote-coding v "remote-decoding"))
(loc-enc (tramp-get-local-coding v "local-encoding")) (loc-enc (tramp-get-local-coding v "local-encoding"))
(modes (save-excursion (file-modes filename))) (modes (save-excursion (tramp-default-file-modes filename)))
;; We use this to save the value of ;; We use this to save the value of
;; `last-coding-system-used' after writing the tmp file. ;; `last-coding-system-used' after writing the tmp file.
;; At the end of the function, we set ;; At the end of the function, we set
......
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