files.def
来自「Welcome to PMOS. PMOS is a set of module」· DEF 代码 · 共 78 行
DEF
78 行
DEFINITION MODULE Files;
(********************************************************)
(* *)
(* File operations. *)
(* *)
(* Programmer: P. Moylan *)
(* Last edited: 16 September 1991 *)
(* Status: Working *)
(* *)
(* Random access not yet tested. *)
(* *)
(********************************************************)
FROM SYSTEM IMPORT
(* type *) BYTE, ADDRESS;
FROM IOErrorCodes IMPORT
(* type *) ErrorCode;
TYPE
File; (* is private *)
PROCEDURE OpenFile (VAR (*OUT*) f: File; name: ARRAY OF CHAR;
newfile: BOOLEAN): ErrorCode;
(* Opens the file named by the given character string, and returns *)
(* f as the identification to be used when specifying this file in *)
(* future. The caller must specify newfile = TRUE to create a new *)
(* file, or newfile = FALSE if the intention is to open an existing *)
(* file. It is illegal to open a new file with the same name as an *)
(* existing file; this is to protect against accidental deletions. *)
(* The value returned is an error code (OK if no error). *)
PROCEDURE CloseFile (VAR (*INOUT*) f: File);
(* Closes file f. *)
PROCEDURE EOF (f: File): BOOLEAN;
(* Returns TRUE iff we are currently at the end of file f. *)
PROCEDURE ReadByte (f: File): BYTE;
(* Returns the next byte from the file. *)
PROCEDURE ReadRecord (f: File; buffaddr: ADDRESS; desired: CARDINAL;
VAR (*OUT*) actual: CARDINAL): ErrorCode;
(* Reads up to "desired" bytes from file f to memory location *)
(* "buffaddr". On return, "actual" gives the number of bytes read. *)
PROCEDURE WriteByte (f: File; value: BYTE): ErrorCode;
(* Writes one byte to the file. *)
PROCEDURE WriteRecord (f: File; buffaddr: ADDRESS;
count: CARDINAL): ErrorCode;
(* Writes count bytes from memory location buffaddr. *)
PROCEDURE SetPosition (f: File; position: LONGCARD): ErrorCode;
(* Ensures that the next read or write on this file will be at *)
(* byte number position in the file. (The first byte in the file *)
(* is byte number 0.) If a position greater than the file size *)
(* is specified, the length of the file will increase. *)
PROCEDURE SavePosition (f: File): LONGCARD;
(* Returns the current byte number in file f. *)
PROCEDURE FileSize (f: File): LONGCARD;
(* Returns the length of the file in bytes. *)
END Files.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?