+
+ /* Discard the unwind protect. */
+ specpdl_ptr = specpdl + count;
+
+ if (retry_p)
+ {
+ list = Qnil;
+ goto retry;
+ }
+
+ if (NILP (nosort))
+ list = Fsort (Fnreverse (list),
+ attrs ? Qfile_attributes_lessp : Qstring_lessp);
+
+ RETURN_UNGCPRO (list);
+}
+
+
+DEFUN ("directory-files", Fdirectory_files, Sdirectory_files, 1, 4, 0,
+ doc: /* Return a list of names of files in DIRECTORY.
+There are three 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 that match 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. */)
+ (directory, full, match, nosort)
+ Lisp_Object directory, full, match, nosort;
+{
+ Lisp_Object handler;
+
+ /* If the file name has special constructs in it,
+ call the corresponding file handler. */
+ handler = Ffind_file_name_handler (directory, Qdirectory_files);
+ if (!NILP (handler))
+ {
+ Lisp_Object args[6];
+
+ args[0] = handler;
+ args[1] = Qdirectory_files;
+ args[2] = directory;
+ args[3] = full;
+ args[4] = match;
+ args[5] = nosort;
+ return Ffuncall (6, args);
+ }
+
+ return directory_files_internal (directory, full, match, nosort, 0);
+}
+
+DEFUN ("directory-files-and-attributes", Fdirectory_files_and_attributes,
+ Sdirectory_files_and_attributes, 1, 4, 0,
+ doc: /* Return a list of names of files and their attributes in DIRECTORY.
+There are three 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 that match 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. */)
+ (directory, full, match, nosort)
+ Lisp_Object directory, full, match, nosort;
+{
+ Lisp_Object handler;
+
+ /* If the file name has special constructs in it,
+ call the corresponding file handler. */
+ handler = Ffind_file_name_handler (directory, Qdirectory_files_and_attributes);
+ if (!NILP (handler))
+ {
+ Lisp_Object args[6];
+
+ args[0] = handler;
+ args[1] = Qdirectory_files_and_attributes;
+ args[2] = directory;
+ args[3] = full;
+ args[4] = match;
+ args[5] = nosort;
+ return Ffuncall (6, args);
+ }
+
+ return directory_files_internal (directory, full, match, nosort, 1);