diff options
| author | Jacob McDonnell <jacob@jacobmcdonnell.com> | 2026-04-26 16:38:00 -0400 |
|---|---|---|
| committer | Jacob McDonnell <jacob@jacobmcdonnell.com> | 2026-04-26 16:38:00 -0400 |
| commit | 97d5c458cfa039d857301e1ca7d5af3beb37131d (patch) | |
| tree | b460cd850d0537eb71806ba30358840377b27688 /static/inferno/man2/sys-dirread.2 | |
| parent | b89dc2331a50c63f8b33272a5c4c61ab98abdaa3 (diff) | |
build: Better Build System
Diffstat (limited to 'static/inferno/man2/sys-dirread.2')
| -rw-r--r-- | static/inferno/man2/sys-dirread.2 | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/static/inferno/man2/sys-dirread.2 b/static/inferno/man2/sys-dirread.2 new file mode 100644 index 00000000..d39c9b93 --- /dev/null +++ b/static/inferno/man2/sys-dirread.2 @@ -0,0 +1,59 @@ +.TH SYS-DIRREAD 2 +.SH NAME +dirread \- read directory +.SH SYNOPSIS +.EX +include "sys.m"; +sys := load Sys Sys->PATH; + +dirread: fn(fd: ref FD): (int, array of Dir); +.EE +.SH DESCRIPTION +.B Dirread +reads the contents of the directory pointed to by the open file descriptor +.IR fd , +returning a tuple containing an array +with one +.B Dir +structure for each directory entry read. +These +.B Dir +structures are equivalent to the result of a +.B stat +call on each file in the directory. +See +.IR sys-stat (2) +for a description of +.B stat +and +.BR Dir . +.PP +A successful +.B 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. +.PP +Seeks (see +.IR sys-seek (2)) +are allowed on directories only to seek to the start. +.PP +In general, several calls to +.B dirread +will be needed to read the whole directory. +.IR Readdir (2) +provides functions that return all the directory entries at once, +optionally sorted. +.SH SEE ALSO +.IR readdir (2), +.IR sys-intro (2), +.IR sys-open (2), +.IR sys-read (2), +.IR sys-seek (2), +.IR sys-stat (2) +.SH DIAGNOSTICS +The integer in +.BR 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. |
