DEFINITION File; (* SJ *)

(* file handling. Some GEMDOS procedures have been extended *)

IMPORT SYSTEM;

CONST (* standard handles *)
  STDIN* = 0; STDOUT* = 1; STDERROR* = 2; STDLIST* = 3; RS232* = 4;
  NULL* = 5;

  (* modi for Fopen *)
  read* = 0; write* = 1; rdwr* = 2;

  (* file attributes *)
  rdonly* = 0; hidden* = 1; system* = 2; label* = 3; subdir* = 4; archiv* = 5;

  (* modi for Fseek *)
  absbeg* = 0; relative* = 1; absend* = 2;

  (* modi for Fdatime *)
  get* = 0; set* = 1;


TYPE dtarec*    = RECORD
                    Search* : ARRAY 12 OF CHAR;
                    rsv     : ARRAY 8 OF CHAR;
                    Attrib* : INTEGER;
                    Time*   : INTEGER;
                    Date*   : INTEGER;
                    Length* : LONGINT;
                    Name*   : ARRAY 14 OF CHAR;
                  END(*RECORD*);
     dta*       = POINTER TO dtarec;
     datime*    = RECORD
                    Time*   : INTEGER;
                    Date*   : INTEGER;
                  END(*RECORD*);


VAR Dta* : dtarec;

(* used as disk transfer record. Is set with Setdtaat initialization time *)


(* all procedures except Search show an error message before terminating
   with return of FALSE.
*)

PROCEDURE- Setdta* (DtaAdr : SYSTEM.PTR) 26,1;


PROCEDURE- Getdta* () : SYSTEM.PTR 47,1;


PROCEDURE Create* (Name : ARRAY OF CHAR; Attribs : SET;
                   VAR Handle : INTEGER) : BOOLEAN;


PROCEDURE Open* (Name : ARRAY OF CHAR; Mode : INTEGER; VAR Handle  : INTEGER)
               : BOOLEAN;


PROCEDURE Close* (Handle : INTEGER);


PROCEDURE Read* (Handle : INTEGER; VAR Count : LONGINT; Buffer : SYSTEM.PTR)
                 : BOOLEAN;


PROCEDURE Write* (Handle : INTEGER; VAR Count : LONGINT; Buffer : SYSTEM.PTR)
                  : BOOLEAN;


PROCEDURE Delete* (Name : ARRAY OF CHAR) : BOOLEAN;


PROCEDURE Seek* (Handle : INTEGER; Bytes : LONGINT; Mode : INTEGER;
                 VAR FilePtr : LONGINT) : BOOLEAN;


PROCEDURE Attrib* (Name : ARRAY OF CHAR; Mode : INTEGER; VAR Attribs : SET)
                   : BOOLEAN;


PROCEDURE Dup* (StdHandle : INTEGER; VAR Handle : INTEGER) : BOOLEAN;


PROCEDURE Force* (StdHandle,NstdHandle : INTEGER) : BOOLEAN;


PROCEDURE Sfirst* (Name : ARRAY OF CHAR; Attribs : SET) : BOOLEAN;


PROCEDURE Snext* () : BOOLEAN;


PROCEDURE Rename* (Old,New : ARRAY OF CHAR) : BOOLEAN;


PROCEDURE Datime* (Handle : INTEGER; VAR DateTime : datime; Mode : INTEGER);


PROCEDURE Search* (Name : ARRAY OF CHAR; VAR Length : LONGINT) : BOOLEAN;

(* searches a file, returns its length and TRUE if found *)


PROCEDURE Load* (Name : ARRAY OF CHAR; BegSpace,EndSpace : LONGINT;
                 VAR Begad : SYSTEM.PTR; Length : LONGINT) : BOOLEAN;

(* loads a file and allocates its space. BegSpace is added in front
   and EndSpace at the end of the file. The file length and the begin
   address are returned.
*)

PROCEDURE LoadTo* (Name : ARRAY OF CHAR; Begad : SYSTEM.PTR;
                   VAR Length : LONGINT) : BOOLEAN;

(* loads a file to the desired address and return its length *)


PROCEDURE Save* (Name : ARRAY OF CHAR; Begad : SYSTEM.PTR; Length : LONGINT)
                 : BOOLEAN;

(* saves a file from Begad with Length *)


END File.
