Function: project--files-in-directory

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

Signature

(project--files-in-directory DIR IGNORES &optional FILES)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/project.el.gz
(defun project--files-in-directory (dir ignores &optional files)
  (require 'find-dired)
  (require 'xref)
  (defvar find-name-arg)
  (let* ((default-directory dir)
         ;; Make sure ~/ etc. in local directory name is
         ;; expanded and not left for the shell command
         ;; to interpret.
         (localdir (file-name-unquote (file-local-name (expand-file-name dir))))
         (dfn (directory-file-name localdir))
         (command (format "%s -H . %s -type f %s -print0"
                          find-program
                          (xref--find-ignores-arguments ignores "./")
                          (if files
                              (concat (shell-quote-argument "(")
                                      " " find-name-arg " "
                                      (mapconcat
                                       #'shell-quote-argument
                                       (split-string files)
                                       (concat " -o " find-name-arg " "))
                                      " "
                                      (shell-quote-argument ")"))
                            "")))
         res)
    (with-temp-buffer
      (let ((status
             (process-file-shell-command command nil t))
            (pt (point-min)))
        (unless (zerop status)
          (error "File listing failed: %s" (buffer-string)))
        (goto-char pt)
        (while (search-forward "\0" nil t)
          (push (buffer-substring-no-properties (1+ pt) (1- (point)))
                res)
          (setq pt (point)))))
    (project--remote-file-names
     (mapcar (lambda (s) (concat dfn s))
             (sort res #'string<)))))