Function: tramp-sh-handle-file-ownership-preserved-p

tramp-sh-handle-file-ownership-preserved-p is a byte-compiled function defined in tramp-sh.el.gz.

Signature

(tramp-sh-handle-file-ownership-preserved-p FILENAME &optional GROUP)

Documentation

Like file-ownership-preserved-p for Tramp files.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-sh.el.gz
(defun tramp-sh-handle-file-ownership-preserved-p (filename &optional group)
  "Like `file-ownership-preserved-p' for Tramp files."
  (with-parsed-tramp-file-name (expand-file-name filename) nil
    (with-tramp-file-property
	v localname
	(format "file-ownership-preserved-p%s" (if group "-group" ""))
      (let ((attributes (file-attributes filename 'integer)))
	;; Return t if the file doesn't exist, since it's true that no
	;; information would be lost by an (attempted) delete and create.
	(or (null attributes)
	    (and
	     (= (file-attribute-user-id attributes)
		(tramp-get-remote-uid v 'integer))
	     (or (not group)
		 ;; On BSD-derived systems files always inherit the
                 ;; parent directory's group, so skip the group-gid
                 ;; test.
                 (tramp-check-remote-uname v (rx (| "BSD" "DragonFly" "Darwin")))
		 (= (file-attribute-group-id attributes)
		    (tramp-get-remote-gid v 'integer)))))))))