Function: directory-files

directory-files is a function defined in dired.c.

Signature

(directory-files DIRECTORY &optional FULL MATCH NOSORT COUNT)

Documentation

Return a list of names of files in DIRECTORY.

There are four optional arguments: If FULL is non-nil, return absolute file names. Otherwise return names
 that are relative to the specified directory.
If MATCH is non-nil, mention only file names whose non-directory part
 matches the regexp MATCH.
If NOSORT is non-nil, the list is not sorted--its order is unpredictable.
 Otherwise, the list returned is sorted with string-lessp.
 NOSORT is useful if you plan to sort the result yourself.
If COUNT is non-nil and a natural number, the function will return
 COUNT number of file names (if so many are present).

Other relevant functions are documented in the file group.

View in manual

Probably introduced at or before Emacs version 20.4.

Shortdoc

;; file
(directory-files "/tmp/")
    e.g. => ("." ".." ".ICE-unix" ".Test-unix")

Source Code

// Defined in /usr/src/emacs/src/dired.c
{
  directory = Fexpand_file_name (directory, Qnil);

  /* If the file name has special constructs in it,
     call the corresponding file name handler.  */
  Lisp_Object handler = Ffind_file_name_handler (directory, Qdirectory_files);
  if (!NILP (handler))
    return calln (handler, Qdirectory_files, directory,
                  full, match, nosort, count);

  return directory_files_internal (directory, full, match, nosort,
                                   false, Qnil, count);
}