home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Carousel
/
CAROUSEL.cdr
/
mactosh
/
lang
/
mod4.hqx
/
M2-4.pit
/
M2FILES.DEF
< prev
next >
Wrap
Text File
|
1985-04-25
|
4KB
|
99 lines
DEFINITION MODULE M2Files; (* LG 22.07.82 , 14.06.83 PF *)
(************************) (* adapted for MacIntosh by Franz Kronseder, 17.02.85 *)
FROM SYSTEM IMPORT WORD;
EXPORT QUALIFIED
File, eolc,
Open, Create, Close, Delete, Rename, GetPos, SetPos, Reset,
ReadChar, WriteChar, ReadWord, WriteWord, ModifyWord,
EndFile,SetTypeandCreator,GetTypeandCreator;
CONST eolc = 15C; (* end of line character for character files *)
TYPE File;
PROCEDURE Open (VAR f: File; VAR name: ARRAY OF CHAR;
readonly: BOOLEAN;
VAR done: BOOLEAN);
(* Open a file already existing in directory. readonly = to read it *)
PROCEDURE Create (VAR f: File; VAR name: ARRAY OF CHAR;
VAR done: BOOLEAN);
(* Open a new file. If an file with the same name already exists, then
the old file is preserved.
Close will then destroy the old file, and catalog the new file.
Delete will then destroy the new file, and keep the old file. *)
PROCEDURE Close(VAR f: File; VAR done: BOOLEAN);
(* Close a file, enter a new name into directory *)
PROCEDURE Delete(VAR f: File; VAR done: BOOLEAN);
(* Close a file, remove from directory *)
PROCEDURE Rename(VAR oldname, newname: ARRAY OF CHAR; VAR done: BOOLEAN);
(* Rename an existing file. the file must not be open *)
(* Rename is not required by the compiler *)
PROCEDURE GetPos(VAR f: File; VAR highpos, lowpos: CARDINAL);
(* Get current position of the file *)
PROCEDURE SetPos(VAR f: File; highpos, lowpos: CARDINAL);
(* Set file to indicated position.
<highpos,lowpos> is byte-position as a 2n-bit number *)
PROCEDURE Reset(VAR f: File);
(* Position the file at the beginning and set to idle mode *)
PROCEDURE ReadChar(VAR f: File; VAR ch: CHAR);
(* Read a character from file *)
PROCEDURE WriteChar(VAR f: File; ch: CHAR);
(* Write a character to file *)
PROCEDURE ReadWord(VAR f: File; VAR w: WORD);
(* Read a word from file *)
PROCEDURE WriteWord(VAR f: File; w: WORD);
(* Write a word to file *)
PROCEDURE ModifyWord(VAR f: File; w: WORD);
(* Modify a word on file *)
PROCEDURE EndFile(VAR f: File): BOOLEAN;
(* End of file reached ( TRUE when reading the EOF marker, or when
in write mode.PF) *)
(* specification notes:
if an error occurs, then M2Files must print the operating system dependent
error details. The Compiler or Linker doesnt want to know about it.
but - for Open, if the file doesn't exist, then M2Files must not display
an error message. The compiler will handle it by trying on the LIB
device etc, and display the message itself, if this also fails.
Writing on an existing file means, the file should be truncated at the
current position.
Do not mix Read, Write and Modify modes, unless calling Reset between.
Do not mix Char and Word calls (file structure may be different).
*)
(* the following procedures will work on open files *)
PROCEDURE SetTypeandCreator (VAR f:File; VAR FType,Creator:ARRAY OF CHAR;VAR done:BOOLEAN);
PROCEDURE GetTypeandCreator (VAR f:File; VAR FType,Creator:ARRAY OF CHAR;VAR done:BOOLEAN);
(* These notes are the Macintosh Version of M2Files:
- a 'file name' in Open/Create/Rename consists of the volume name and
the file name proper, separated by a : . The Macintosh O.S. allows any
char in a name (even unprintable), except a : .
Valid Example: MYDISK:daten.DAT
- using Set/GetTypeAndCreator will only disturb you, unless you know a lot
about the Mac O.S.
*)
END M2Files.
(*=================================================================================================*)