= dirread: read directory include "sys.m"; sys := load Sys Sys->PATH; dirread: fn(fd: ref FD): (int, array of Dir);Dirread reads the contents of the directory pointed to by theopen file descriptor fd, returning a tuple containing anarray with one Dir structure for each directory entry read.These Dir structures are equivalent to the result of a statcall on each file in the directory. See sys-stat(2) for adescription of stat and Dir.A successful dirread returns a tuple giving the number ofentries read and the resulting array. A return of (0,nil)indicates the end of the directory. Directory entries arevariable length in general; the file offset is advanced bythe number of bytes actually read.Seeks (see sys-seek(2)) are allowed on directories only toseek to the start.In general, several calls to dirread will be needed to readthe whole directory. Readdir (2) provides functions thatreturn all the directory entries at once, optionally sorted.== see ALSOreaddir(2), sys-intro(2), sys-open(2), sys-read(2), sys-seek(2), sys-stat(2)== diagnosticsThe integer in dirread's return tuple has a value of -1 onerror, and 0 on end of file. The array element of the tupleis nil in both cases.
= dirread: read directory
include "sys.m";
sys := load Sys Sys->PATH;
dirread: fn(fd: ref FD): (int, array of Dir);
Dirread reads the contents of the directory pointed to by the
open file descriptor fd, returning a tuple containing an
array with one Dir structure for each directory entry read.
These Dir structures are equivalent to the result of a stat
call on each file in the directory. See sys-stat(2) for a
description of stat and Dir.
A successful dirread returns a tuple giving the number of
entries read and the resulting array. A return of (0,nil)
indicates the end of the directory. Directory entries are
variable length in general; the file offset is advanced by
the number of bytes actually read.
Seeks (see sys-seek(2)) are allowed on directories only to
seek to the start.
In general, several calls to dirread will be needed to read
the whole directory. Readdir (2) provides functions that
return all the directory entries at once, optionally sorted.
== see ALSO
readdir(2), sys-intro(2), sys-open(2), sys-read(2), sys-
seek(2), sys-stat(2)
== diagnostics
The integer in dirread's return tuple has a value of -1 on
error, and 0 on end of file. The array element of the tuple
is nil in both cases.