Function: tramp-smb-handle-file-attributes

tramp-smb-handle-file-attributes is a byte-compiled function defined in tramp-smb.el.gz.

Signature

(tramp-smb-handle-file-attributes FILENAME &optional ID-FORMAT)

Documentation

Like file-attributes for Tramp files.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-smb.el.gz
(defun tramp-smb-handle-file-attributes (filename &optional id-format)
  "Like `file-attributes' for Tramp files."
  (unless id-format (setq id-format 'integer))
  (ignore-errors
    (with-parsed-tramp-file-name filename nil
      (with-tramp-file-property
	  v localname (format "file-attributes-%s" id-format)
	(if (tramp-smb-get-stat-capability v)
	    (tramp-smb-do-file-attributes-with-stat v id-format)
	  ;; Reading just the filename entry via "dir localname" is not
	  ;; possible, because when filename is a directory, some
	  ;; smbclient versions return the content of the directory, and
	  ;; other versions don't.  Therefore, the whole content of the
	  ;; upper directory is retrieved, and the entry of the filename
	  ;; is extracted from.
	  (let* ((entries (tramp-smb-get-file-entries
			   (file-name-directory filename)))
		 (entry (assoc (file-name-nondirectory filename) entries))
		 (uid (if (equal id-format 'string) "nobody" -1))
		 (gid (if (equal id-format 'string) "nogroup" -1))
		 (inode (tramp-get-inode v))
		 (device (tramp-get-device v)))

	    ;; Check result.
	    (when entry
	      (list (and (tramp-compat-string-search "d" (nth 1 entry))
			 t)              ;0 file type
		    -1	                 ;1 link count
		    uid	                 ;2 uid
		    gid	                 ;3 gid
		    tramp-time-dont-know ;4 atime
		    (nth 3 entry)        ;5 mtime
		    tramp-time-dont-know ;6 ctime
		    (nth 2 entry)        ;7 size
		    (nth 1 entry)        ;8 mode
		    nil	                 ;9 gid weird
		    inode	         ;10 inode number
		    device))))))))       ;11 file system number