# The FileRd interface

A `FileRd.T`, or file reader, is a reader on a `File.T`. buffered file I/O

file buffered I/O

    INTERFACE FileRd;

    IMPORT Rd, File, OSError, Pathname;

    TYPE
      T <: Public;
      Public = Rd.T OBJECT METHODS
        init(h: File.T): T RAISES {OSError.E}
      END;

If `r` is a file reader and `h` is a file handle, the call `r.init(h)` initializes `r` so that reading `r` reads characters from `h`, and so that closing `r` closes `h`.

If `h` is a regular file handle, `r.init(h)` causes `r` to be a nonintermittent, seekable reader and initializes `cur(r)` to `cur(h)`.

For any other file handle `h`, `r.init(h)` causes `r` to be an intermittent, nonseekable reader and initializes `cur(r)` to zero.

If a subsequent reader operation on `r` raises `Rd.Failure`, the associated exception argument is the `AtomList.T` argument accompanying an `OSError.E` exception from a file operation on `h`.

    PROCEDURE Open(p: Pathname.T): T RAISES {OSError.E};

Return a file reader whose source is the file named `p`. If the file does not exist, `OSError.E` is raised with an implementation-defined code.

The call `Open(p)` is equivalent to

     RETURN NEW(T).init(FS.OpenFileReadonly(p))

    END FileRd.