Function: tramp-skeleton-directory-files-and-attributes

tramp-skeleton-directory-files-and-attributes is a macro defined in tramp.el.gz.

Signature

(tramp-skeleton-directory-files-and-attributes DIRECTORY &optional FULL MATCH NOSORT ID-FORMAT COUNT &rest BODY)

Documentation

Skeleton for tramp-*-handle-directory-files-and-attributes.

BODY is the backend specific code.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
(defmacro tramp-skeleton-directory-files-and-attributes
    (directory &optional full match nosort id-format count &rest body)
  "Skeleton for `tramp-*-handle-directory-files-and-attributes'.
BODY is the backend specific code."
  (declare (indent 6) (debug t))
  `(with-parsed-tramp-file-name (expand-file-name ,directory) nil
     (tramp-barf-if-file-missing v ,directory
       (if (not (file-directory-p ,directory))
	   ;; Trigger the `file-missing' error.
	   (signal 'error nil)
	 (let ((temp
		(copy-tree
		 (mapcar
		  (lambda (x)
		    (cons
		     (car x)
		     (tramp-convert-file-attributes
			 v (expand-file-name (car x) localname)
			 ,id-format (cdr x))))
		  (with-tramp-file-property
		      v localname "directory-files-and-attributes"
		    ,@body))))
	       result item)

	   (while temp
	     (setq item (pop temp))
	     (when (or (null ,match) (string-match-p ,match (car item)))
	       (when ,full
		 (setcar item (expand-file-name (car item) ,directory)))
	       (push item result)))

	   (unless ,nosort
	     (setq result
		   (sort result (lambda (x y) (string< (car x) (car y))))))

	   (when (and (natnump ,count) (> ,count 0))
	     (setq result (tramp-compat-ntake ,count result)))

	   (or result
	       ;; The scripts could fail, for example with huge file size.
	       (tramp-handle-directory-files-and-attributes
		,directory ,full ,match ,nosort ,id-format ,count)))))))