Function: filesets-directory-files

filesets-directory-files is a byte-compiled function defined in filesets.el.gz.

Signature

(filesets-directory-files DIR &optional PATTERN WHAT FULL-FLAG MATCH-DIRS-FLAG)

Documentation

Get WHAT (:files or :dirs) in DIR.

If PATTERN is provided return only those entries matching this regular expression. If MATCH-DIRS-FLAG is non-nil, also match directory entries. Return full path if FULL-FLAG is non-nil.

Source Code

;; Defined in /usr/src/emacs/lisp/filesets.el.gz
(defun filesets-directory-files (dir &optional
				     pattern what full-flag match-dirs-flag)
  "Get WHAT (:files or :dirs) in DIR.
If PATTERN is provided return only those entries matching this
regular expression.
If MATCH-DIRS-FLAG is non-nil, also match directory entries.
Return full path if FULL-FLAG is non-nil."
  (filesets-message 2 "Filesets: scanning %S" dir)
  (cond
   ((file-exists-p dir)
    (let ((files nil)
	  (dirs  nil))
      (dolist (this (file-name-all-completions "" dir))
	(cond
	 ((string-match-p "^\\.+/$" this)
	  nil)
	 ((string-match-p "[:/\\]$" this)
	  (when (or (not match-dirs-flag)
		    (not pattern)
		    (string-match-p pattern this))
	    (filesets-message 5 "Filesets: matched dir %S with pattern %S"
			      this pattern)
	    (push this dirs)))
	 (t
	  (when (or (not pattern)
		    (string-match-p pattern this))
	    (filesets-message 5 "Filesets: matched file %S with pattern %S"
			      this pattern)
	    (push (if full-flag
		      (concat (file-name-as-directory dir) this)
		    this)
		  files)))))
      (cond
       ((equal what ':dirs)
	(filesets-conditional-sort dirs))
       ((equal what ':files)
	(filesets-conditional-sort files))
       (t
	(append (filesets-conditional-sort files)
		(filesets-conditional-sort dirs))))))
   (filesets-be-docile-flag
    (filesets-message 1 "Filesets: %S doesn't exist" dir)
    nil)
   (t
    (error "Filesets: %s does not exist" dir))))