SYS-DIRREAD(2)                                     SYS-DIRREAD(2)

     NAME
          dirread - read directory

     SYNOPSIS
          include "sys.m";
          sys := load Sys Sys->PATH;

          dirread:  fn(fd: ref FD, dir: array of Dir): int;

     DESCRIPTION
          Dirread reads the contents of the directory pointed to by
          the open file descriptor fd, filling in the array dir with
          one Dir structure for each element.  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 the number of entries read, up
          to the length of array dir; the number returned may be less
          than the number requested.  The file offset is advanced by
          the number of bytes actually read.  A return of 0 indicates
          the end of the directory.

          Seeks (see sys-seek(2)) are not allowed on directories.

     SEE ALSO
          sys-intro(2), sys-open(2), sys-read(2), sys-seek(2), sys-
          stat(2)

     Page 1                       Plan 9            (printed 12/22/24)