ftw: Add `scandir'.

Suggested by Nala Ginrut <nalaginrut@gmail.com>.

* module/ice-9/ftw.scm (scandir): New procedure.
* test-suite/tests/ftw.test ("scandir"): New test prefix.
* doc/ref/misc-modules.texi (File Tree Walk): Document `scandir'.
This commit is contained in:
Ludovic Courtès 2011-12-18 21:14:33 +01:00
commit 1629429d63
3 changed files with 51 additions and 1 deletions

View file

@ -1249,6 +1249,18 @@ to `du --apparent-size' with GNU Coreutils.)"
The alternative C-like functions are described below.
@defun scandir name [select? [entry<?]]
Return the list of the names of files contained in directory @var{name}
that match predicate @var{select?} (by default, all files). The
returned list of file names is sorted according to @var{entry<?}, which
defaults to @code{string-locale<?} such that file names are sorted in
the locale's alphabetical order (@pxref{Text Collation}).
This procedure is modeled after the C library function of the same name
(@pxref{Scanning Directory Content,,, libc, GNU C Library Reference
Manual}).
@end defun
@defun ftw startname proc ['hash-size n]
Walk the file system tree descending from @var{startname}, calling
@var{proc} for each file and directory.