home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Modula / Source / M2FILES.DEF < prev    next >
Text File  |  1985-04-25  |  4KB  |  99 lines

  1. DEFINITION MODULE M2Files;  (* LG 22.07.82 , 14.06.83 PF *)
  2. (************************)  (* adapted for MacIntosh by Franz Kronseder, 17.02.85 *)
  3.  
  4.   FROM SYSTEM IMPORT WORD;
  5.  
  6.   EXPORT QUALIFIED
  7.     File,    eolc,
  8.     Open, Create, Close, Delete, Rename, GetPos, SetPos, Reset,
  9.     ReadChar, WriteChar, ReadWord, WriteWord, ModifyWord,
  10.     EndFile,SetTypeandCreator,GetTypeandCreator;
  11.  
  12.   CONST eolc = 15C; (* end of line character for character files *)
  13.   TYPE File;
  14.  
  15.  
  16.   PROCEDURE Open (VAR f: File; VAR name: ARRAY OF CHAR;
  17.                       readonly: BOOLEAN;
  18.                   VAR done: BOOLEAN);
  19.     (* Open a file already existing in directory. readonly = to read it *)
  20.  
  21.   PROCEDURE Create (VAR f: File; VAR name: ARRAY OF CHAR;
  22.                     VAR done: BOOLEAN);
  23.     (* Open a new file. If an file with the same name already exists, then
  24.        the old file is preserved.
  25.        Close will then destroy the old file, and catalog the new file.
  26.        Delete will then destroy the new file, and keep the old file.  *)
  27.  
  28.   PROCEDURE Close(VAR f: File; VAR done: BOOLEAN);
  29.     (* Close a file, enter a new name into directory *)
  30.  
  31.   PROCEDURE Delete(VAR f: File; VAR done: BOOLEAN);
  32.     (* Close a file, remove from directory *)
  33.  
  34.   PROCEDURE Rename(VAR oldname, newname: ARRAY OF CHAR; VAR done: BOOLEAN);
  35.     (* Rename an existing file. the file must not be open *)
  36.     (* Rename is not required by the compiler *)
  37.  
  38.   PROCEDURE GetPos(VAR f: File; VAR highpos, lowpos: CARDINAL);
  39.     (* Get current position of the file *)
  40.  
  41.   PROCEDURE SetPos(VAR f: File; highpos, lowpos: CARDINAL);
  42.     (* Set file to indicated position.
  43.        <highpos,lowpos> is  byte-position as a 2n-bit number *)
  44.  
  45.   PROCEDURE Reset(VAR f: File);
  46.     (* Position the file at the beginning and set to idle mode *)
  47.  
  48.   PROCEDURE ReadChar(VAR f: File; VAR ch: CHAR);
  49.     (* Read a character from file *)
  50.  
  51.   PROCEDURE WriteChar(VAR f: File; ch: CHAR);
  52.     (* Write a character to file *)
  53.  
  54.   PROCEDURE ReadWord(VAR f: File; VAR w: WORD);
  55.     (* Read a word from file *)
  56.  
  57.   PROCEDURE WriteWord(VAR f: File; w: WORD);
  58.     (* Write a word to file *)
  59.  
  60.   PROCEDURE ModifyWord(VAR f: File; w: WORD);
  61.     (* Modify a word on file *)
  62.  
  63.   PROCEDURE EndFile(VAR f: File): BOOLEAN;
  64.     (* End of file reached ( TRUE when reading the EOF marker, or when
  65.        in write mode.PF) *)
  66.  
  67. (* specification notes:
  68.    if an error occurs, then M2Files must print the operating system dependent
  69.    error details. The Compiler or Linker doesnt want to know about it.
  70.    but - for Open, if the file doesn't exist, then M2Files must not display
  71.          an error message. The compiler will handle it by trying on the LIB
  72.          device etc, and display the message itself, if this also fails.
  73.  
  74.    Writing on an existing file means, the file should be truncated at the
  75.    current position.
  76.  
  77.    Do not mix Read, Write and Modify modes, unless calling Reset between.
  78.    Do not mix Char and Word calls (file structure may be different).
  79.  
  80. *)
  81.  
  82. (* the following procedures will work on open files *)
  83. PROCEDURE SetTypeandCreator (VAR f:File; VAR FType,Creator:ARRAY OF CHAR;VAR done:BOOLEAN);
  84. PROCEDURE GetTypeandCreator (VAR f:File; VAR FType,Creator:ARRAY OF CHAR;VAR done:BOOLEAN);
  85.  
  86.  
  87. (* These notes are the Macintosh Version of M2Files:
  88.  
  89. - a 'file name' in Open/Create/Rename consists of the volume name and 
  90.   the file name proper, separated by a : . The Macintosh O.S. allows any
  91.   char in a name (even unprintable), except a : .
  92.   Valid Example:  MYDISK:daten.DAT
  93.   
  94. - using Set/GetTypeAndCreator will only disturb you, unless you know a lot
  95.   about the Mac O.S.
  96. *)
  97. END M2Files.
  98. (*=================================================================================================*)
  99.