IO(2) IO(2) NAME readn, readfile, readdev, copy - file reading utilities SYNOPSIS include "io.m"; io := load Io Io->PATH; readn: fn(fd: ref Sys->FD, buf: array of byte, n: int): int; readfile: fn(fd: ref Sys->FD): array of byte; readdev fn(fname: string, dflt: string): string; copy: fn(dfd, sfd: ref Sys->FD): int; DESCRIPTION Io provides auxiliary functions used for file I/O, as a con- venience. Readn reads n bytes from the give fd (maybe less due to errors or EOF). Readfile reads all the data availabe at fd and stops only when meeting EOF. This should not be used for huge files. Copy copies all data yet to be read from sfd to dfd and returns the number of bytes copied. Readdev is used to read strings from device files. It read the contents and removes the trailing newline (if any) and returns the string just read or dflt upon errors. SOURCE /usr/octopus/port/lib/io.b