Function: directory-empty-p

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

Signature

(directory-empty-p DIR)

Documentation

Return t if DIR names an existing directory containing no other files.

Return nil if DIR does not name a directory, or if there was trouble determining whether DIR is a directory or empty.

Symbolic links to directories count as directories. See file-symlink-p to distinguish symlinks.

Probably introduced at or before Emacs version 28.1.

Aliases

org-directory-empty-p tramp-compat-directory-empty-p

Source Code

;; Defined in /usr/src/emacs/lisp/files.el.gz
(defun directory-empty-p (dir)
  "Return t if DIR names an existing directory containing no other files.
Return nil if DIR does not name a directory, or if there was
trouble determining whether DIR is a directory or empty.

Symbolic links to directories count as directories.
See `file-symlink-p' to distinguish symlinks."
  (and (file-directory-p dir)
       (null (directory-files dir nil directory-files-no-dot-files-regexp t 1))))