Copyright (C) 1994, Digital Equipment Corp. INTERFACEIn this interface we reveal that all UnixFilePosix ; IMPORT File, OSError, Pipe, Ustat;
File.T
s 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 ofFile.T
, based on the characteristics of the opened file descriptorfd
and directionsds
.
PROCEDURE NewPipe(fd: INTEGER; ds: DirectionSet): Pipe.T;
Create aPipe.T
based onfd
andds
. It is an unchecked (but safe) error iffd
is notS_IFPIPE
,S_IFPORT
, orS_IFSOCK
.
PROCEDURE FileTypeFromStatbuf(READONLY statbuf: Ustat.struct_stat) : File.Type;
Return theFile.Type
corresponding mostly closely toWord.And(statbuf.st_mode, Ustat.S_IFMT)
.
END FilePosix.