(when (file-exists-p 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)
"Like `file-directory-p' for Tramp files."
;; Care must be taken that this function returns `t' for symlinks
;; KEEP-DATE handling.
(when keep-date (set-file-times newname (nth 5 (file-attributes filename))))
;; 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.
(unless (eq op 'copy) (delete-file filename)))
(condition-case nil
(when (and keep-date (not preserve-uid-gid))
(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)))))
(defun tramp-do-copy-or-rename-file-out-of-band (op filename newname keep-date)
;; Set the mode.
(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.
(unless (eq op 'copy)
(tramp-message v 5 "Decoding remote file %s...done" filename)
;; Set proper permissions.
- (set-file-modes tmpfile (file-modes filename))
+ (set-file-modes tmpfile (tramp-default-file-modes filename))
;; Set local user ownership.
(tramp-set-file-uid-gid tmpfile)))
(let ((backup-directory-alist
;; Emacs case
(when (boundp 'backup-directory-alist)
- (if (boundp 'tramp-backup-directory-alist)
+ (if (symbol-value 'tramp-backup-directory-alist)
(mapcar
'(lambda (x)
(cons
(bkup-backup-directory-info
;; XEmacs case
(when (boundp 'bkup-backup-directory-info)
- (if (boundp 'tramp-bkup-backup-directory-info)
+ (if (symbol-value 'tramp-bkup-backup-directory-info)
(mapcar
'(lambda (x)
(nconc
(let ((rem-dec (tramp-get-remote-coding v "remote-decoding"))
(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
;; `last-coding-system-used' after writing the tmp file.
;; At the end of the function, we set