Charles.Forsyth20060303-partialeea662d19 years agoHistory
59 lines · 1.3 KB · Text
RawDownload
.TH SYS-DIRREAD 2.SH NAMEdirread \- read directory.SH SYNOPSIS.EXinclude "sys.m";sys := load Sys Sys->PATH; dirread:  fn(fd: ref FD): (int, array of Dir);.EE.SH DESCRIPTION.B Dirreadreads the contents of the directory pointed to by the open file descriptor.IR fd ,returning a tuple containing an arraywith one.B Dirstructure for each directory entry read.These.B Dirstructures are equivalent to the result of a.B statcall on each file in the directory.See.IR sys-stat (2)for a description of.B statand.BR Dir ..PPA successful.B dirreadreturns 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..PPSeeks (see.IR sys-seek (2))are allowed on directories only to seek to the start..PPIn general, several calls to.B dirreadwill be needed to read the whole directory..I 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 DIAGNOSTICSThe integer in.BR dirread 'sreturn 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.