1 (* Library module defined by the International Standard
2 Information technology - programming languages
3 BS ISO/IEC 10514-1:1996E Part 1: Modula-2, Base Language.
5 Copyright ISO/IEC (International Organization for Standardization
6 and International Electrotechnical Commission) 1996-2021.
8 It may be freely copied for the purpose of implementation (see page
9 707 of the Information technology - Programming languages Part 1:
10 Modula-2, Base Language. BS ISO/IEC 10514-1:1996). *)
12 DEFINITION MODULE StreamFile;
14 (* Independent sequential data streams *)
16 IMPORT IOChan, ChanConsts;
19 ChanId = IOChan.ChanId;
20 FlagSet = ChanConsts.FlagSet;
21 OpenResults = ChanConsts.OpenResults;
23 (* Accepted singleton values of FlagSet *)
26 read = FlagSet{ChanConsts.readFlag}; (* input operations are requested/available *)
27 write = FlagSet{ChanConsts.writeFlag}; (* output operations are requested/available *)
28 old = FlagSet{ChanConsts.oldFlag}; (* a file may/must/did exist before the channel is
30 text = FlagSet{ChanConsts.textFlag}; (* text operations are requested/available *)
31 raw = FlagSet{ChanConsts.rawFlag}; (* raw operations are requested/available *)
34 PROCEDURE Open (VAR cid: ChanId; name: ARRAY OF CHAR;
35 flags: FlagSet; VAR res: OpenResults);
36 (* Attempts to obtain and open a channel connected to a
37 sequential stream of the given name.
38 The read flag implies old; without the raw flag, text is
39 implied. If successful, assigns to cid the identity of
40 the opened channel, and assigns the value opened to res.
41 If a channel cannot be opened as required, the value of
42 res indicates the reason, and cid identifies the invalid
46 PROCEDURE IsStreamFile (cid: ChanId): BOOLEAN;
47 (* Tests if the channel identified by cid is open to a sequential stream. *)
49 PROCEDURE Close (VAR cid: ChanId);
50 (* If the channel identified by cid is not open to a sequential stream, the exception
51 wrongDevice is raised; otherwise closes the channel, and assigns the value identifying
52 the invalid channel to cid.