Copyright (C) 1994, Digital Equipment Corp.
INTERFACE FilePosix;
IMPORT File, OSError, Pipe, Ustat;
In this interface we reveal that all Unix File.Ts have a
file descriptor field, fd.
TYPE T = File.Public OBJECT
fd: INTEGER;
ds: DirectionSet
END;
REVEAL File.T <: T;
TYPE
Direction = {Read, Write};
DirectionSet = SET OF Direction;
CONST
Read = DirectionSet{Direction.Read};
Write = DirectionSet{Direction.Write};
ReadWrite = DirectionSet{Direction.Read, Direction.Write};
PROCEDURE New(fd: INTEGER; ds: DirectionSet): File.T RAISES {OSError.E};
Create the appropriate subtype of File.T, based on the characteristics
of the opened file descriptor fd and directions ds.
PROCEDURE NewPipe(fd: INTEGER; ds: DirectionSet): Pipe.T;
Create a Pipe.T based on fd and ds. It is an unchecked (but safe)
error if fd is not S_IFPIPE, S_IFPORT, or S_IFSOCK.
PROCEDURE FileTypeFromStatbuf(READONLY statbuf: Ustat.struct_stat)
: File.Type;
Return the File.Type corresponding mostly closely to
Word.And(statbuf.st_mode, Ustat.S_IFMT).
END FilePosix.