-
Notifications
You must be signed in to change notification settings - Fork 5
/
FILESYS.DEF
145 lines (117 loc) · 6.5 KB
/
FILESYS.DEF
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
(****************************************************************************)
(* *)
(* DEFINITION MODULE FileSys -- simple file system for the compiler *)
(* *)
(* *)
(* This module allows buffered sequential file I/O. *)
(* *)
(* Each file has to be created by 'AssignName'. *)
(* *)
(* The module is optimized to use small space in memory. *)
(* *)
(* *)
(* *)
(* *)
(* *)
(* *)
(* *)
(* *)
(* *)
(* *)
(* created : Jan - 15 - 1984 pwh *)
(* last updated: Oct - 16 - 1984 pwh *)
(****************************************************************************)
DEFINITION MODULE FileSys;
FROM OpSys IMPORT
FCBFileName;
EXPORT QUALIFIED
File, PathType,
result,
SetSearchPath,
MakeFile, UsesFile,
AssignName,
CreateFile, OpenFile,
ReadByte, EOF, WriteByte,
CloseFile, DisposeFile,
Delete, DeleteFile,
Rename, RenameFile;
CONST
searchPathLength = 6; (* max. 6 drives to search *)
TYPE
File;
PathType = ARRAY [0..searchPathLength-1] OF CHAR;
VAR
result: CARDINAL; (* CP/M return value. *)
(*--------------------------------------------------------------*)
(* PROCEDURE SetSearchPath -- set search path for 'OpenFile'. *)
(*--------------------------------------------------------------*)
PROCEDURE SetSearchPath( newSearchPath: PathType );
(*------------------------------------------------------*)
(* PROCEDURE AssignName -- assign a name to a file and *)
(* prepare its FCB for opening. *)
(*------------------------------------------------------*)
PROCEDURE AssignName( VAR f: File; fname: FCBFileName );
(*------------------------------------------------------*)
(* PROCEDURE CreateFile -- create a file, deleting an *)
(* an existing old version first. FCB must be prepared *)
(* by Assign, i.e. name is assigned, rest cleared. *)
(*------------------------------------------------------*)
PROCEDURE CreateFile( f: File );
(*------------------------------------------------------*)
(* PROCEDURE OpenFile -- open an existing file for read *)
(* FCB has to be prepared by Assign, i.e. name is *)
(* assigned, rest cleared. *)
(*------------------------------------------------------*)
PROCEDURE OpenFile( f: File );
(*------------------------------------------------------*)
(* PROCEDURE CloseFile -- flush a file's buffer and *)
(* close it. *)
(*------------------------------------------------------*)
PROCEDURE CloseFile( f: File );
(*------------------------------------------------------*)
(* PROCEDURE Delete - delete file 'delfil'. *)
(*------------------------------------------------------*)
PROCEDURE Delete( delfil: FCBFileName );
(*------------------------------------------------------*)
(* PROCEDURE DeleteFile -- delete an assigned file. *)
(* This also disposes the file descriptor. *)
(*------------------------------------------------------*)
PROCEDURE DeleteFile( VAR f: File );
(*------------------------------------------------------*)
(* PROCEDURE Rename -- rename 'old' to 'new'. *)
(*------------------------------------------------------*)
PROCEDURE Rename( old, new: FCBFileName );
(*------------------------------------------------------*)
(* PROCEDURE RenameFile -- rename an assigned file. *)
(*------------------------------------------------------*)
PROCEDURE RenameFile( oldFile: File; newName: FCBFileName );
(*------------------------------------------------------*)
(* PROCEDURE ReadByte -- read byte. *)
(*------------------------------------------------------*)
PROCEDURE ReadByte( f: File; VAR ch: CHAR );
(*------------------------------------------------------*)
(* PROCEDURE EOF - test for end of file. *)
(*------------------------------------------------------*)
PROCEDURE EOF( f: File ): BOOLEAN;
(*------------------------------------------------------*)
(* PROCEDURE WriteByte -- write a byte to a specified *)
(* file. *)
(*------------------------------------------------------*)
PROCEDURE WriteByte( f: File; b: CHAR );
(*--------------------------------------------------------------*)
(* PROCEDURE MakeFile -- create a file. Issue an error message *)
(* and abort if operation is unsuccessful. *)
(*--------------------------------------------------------------*)
PROCEDURE MakeFile( VAR f: File; n: FCBFileName );
(*--------------------------------------------------------------*)
(* PROCEDURE UsesFile -- open an existing file. Issue an error *)
(* message and abort if operation is unsuccessful. *)
(*--------------------------------------------------------------*)
PROCEDURE UsesFile( VAR f: File; n: FCBFileName );
(*--------------------------------------------------------------*)
(* PROCEDURE DisposeFile -- dispose a file descriptor after the *)
(* file has been closed or if it is no longer needed. *)
(*--------------------------------------------------------------*)
PROCEDURE DisposeFile( VAR f: File );
END FileSys.