(********************************************************************************

Name         : FileSystem.DEF
Version      : 1.0
Purpose      : FileSystem for Modula-2 compiler
Authors      : cn/jr/ms/red
Modified     : 12.3.86  18:38  cn
State        : should be ok
Requirements : fixkey

********************************************************************************)

DEFINITION MODULE FileSystem;

  FROM SYSTEM IMPORT WORD;

  TYPE
    Response = (done, notdone);

    File     = RECORD
                 refNum:     INTEGER;                 (* unused *)
                 fileHandle,                          (* AMIGAFile *)
                 firstPos:   LONGINT;                 (* FilePos of buffer[0] *)
                 lastPos,                             (* HIGH(buffer)=lastPos-1 *)
                 curPos:     INTEGER;                 (* next to read or write *)
                 res:        Response;
                 eof:        BOOLEAN;
                 dirty:      BOOLEAN;                 (* dirty: buffer changed *)
                 nameString: ARRAY [0..31] OF CHAR;
                 buffer:     ARRAY [0..1024-1] OF CHAR;
               END;

  PROCEDURE Lookup(VAR f: File; filename: ARRAY OF CHAR; new: BOOLEAN); 
  PROCEDURE Close(VAR f: File);
  PROCEDURE Delete(VAR f: File);
(*PROCEDURE Rename(VAR f: File; filename: ARRAY OF CHAR);*)
  PROCEDURE SetPos(VAR f: File; highpos, lowpos: CARDINAL);
  PROCEDURE GetPos(VAR f: File; VAR highpos, lowpos: CARDINAL);
  PROCEDURE Length(VAR f: File; VAR highpos, lowpos: CARDINAL);
  PROCEDURE ReadWord(VAR f: File; VAR w: WORD);
  PROCEDURE WriteWord(VAR f: File; w: WORD);
  PROCEDURE ReadChar(VAR f: File; VAR ch: CHAR);
  PROCEDURE WriteChar(VAR f: File; ch: CHAR);

END FileSystem.
