Function: file-directory-p

file-directory-p is a function defined in fileio.c.

Signature

(file-directory-p FILENAME)

Documentation

Return t if FILENAME names an existing directory.

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

As a special case, this function will also return t if FILENAME is the empty string (""). This quirk is due to Emacs interpreting the empty string (in some cases) as the current directory.

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

Other relevant functions are documented in the file group.

View in manual

Shortdoc

;; file
(file-directory-p "/tmp")
    e.g. => t

Aliases

f-dir-p f-directory? f-directory-p f-dir?

Source Code

// Defined in /usr/src/emacs/src/fileio.c
{
  Lisp_Object absname = expand_and_dir_to_file (filename);

  /* If the file name has special constructs in it,
     call the corresponding file name handler.  */
  Lisp_Object handler = Ffind_file_name_handler (absname, Qfile_directory_p);
  if (!NILP (handler))
    return calln (handler, Qfile_directory_p, absname);

  return file_directory_p (ENCODE_FILE (absname)) ? Qt : Qnil;
}