Function: directory-files-and-attributes

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

Signature

(directory-files-and-attributes DIRECTORY &optional FULL MATCH NOSORT ID-FORMAT COUNT)

Documentation

Return a list of names of files and their attributes in DIRECTORY.

Value is a list of the form:

  ((FILE1 . FILE1-ATTRS) (FILE2 . FILE2-ATTRS) ...)

where each FILEn-ATTRS is the attributes of FILEn as returned by file-attributes.

This function accepts five 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.
 NOSORT is useful if you plan to sort the result yourself.
ID-FORMAT specifies the preferred format of attributes uid and gid, see
 file-attributes for further documentation.
If COUNT is non-nil and a natural number, the function will return
 COUNT number of file names (if so many are present).
On MS-Windows, performance depends on w32-get-true-file-attributes, which see.

Other relevant functions are documented in the file group.

Probably introduced at or before Emacs version 20.4.

Shortdoc

;; file
(directory-files-and-attributes "/tmp/foo")
    -> [it depends]

Aliases

tramp-compat-directory-files-and-attributes

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_and_attributes);
  if (!NILP (handler))
    return call7 (handler, Qdirectory_files_and_attributes,
                  directory, full, match, nosort, id_format, count);

  return directory_files_internal (directory, full, match, nosort,
				   true, id_format, count);
}