|##########|
|#MAGIC   #|CKOLFLHJ
|#PROJECT #|""
|#PATHS   #|"StdProject"
|#FLAGS   #|xx---x--x----xx-----------------
|#USERSW  #|--------------------------------
|#USERMASK#|--------------------------------
|#SWITCHES#|x----xxxxx-xx---
|##########|
DEFINITION MODULE OFiles;

FROM T_Dos      IMPORT EOF,SeekError,OpenErr;
FROM FileSystem IMPORT File;
FROM Resources  IMPORT ContextPtr;
                IMPORT Dos;

EXCEPTION
  ObjectNotFound : "Object not found";

TYPE
  ODirectory  = POINTER TO ODirObj;
  ODirObj     = OBJECT
                  name : STRING(108);
                  lock : Dos.FileLockPtr;
                  con  : ContextPtr;

                  CONSTRUCTOR Create(REF name : STRING;
                                         con  : ContextPtr := NIL);
                  CONSTRUCTOR Clone(whom : ODirectory;
                                    con  : ContextPtr := NIL);
                  DESTRUCTOR Delete;

                  METHOD SubDir(REF name : STRING);
                  METHOD ParentDir;

                  METHOD Exists():BOOLEAN;
                  METHOD BuildUp;

                  METHOD Contains(REF name : STRING):BOOLEAN;

                  $$OwnHeap:=TRUE
                  METHOD FullName():STRING;

                  METHOD Destruct;
                END;

  OFile       = POINTER TO OBJECT
                  file : File;

                  CONSTRUCTOR Open(REF path    : STRING;
                                       dir     : ODirectory := NIL;
                                       new     : BOOLEAN    := FALSE;
                                       buffer  : LONGINT    := $4000;
                                       context : ContextPtr := NIL);
                  DESTRUCTOR Close;

                  METHOD Read(VAR c : CHAR);
                  METHOD ReadBytes(at : ANYPTR;size : LONGINT);
                  METHOD ReadBlock(VAR blk : ANYTYPE);
                  METHOD ReadString(VAR str : STRING);

                  METHOD Write(c : CHAR);
                  METHOD WriteBytes(at : ANYPTR;size : LONGINT);
                  METHOD WriteBlock(REF blk : ANYTYPE);
                  METHOD WriteString(REF str : STRING);

                  METHOD Pos():LONGINT;
                  METHOD SetPos(pos : LONGINT);

                  METHOD Length():LONGINT;
                  METHOD EOF():BOOLEAN;

                  METHOD Destruct;
                END;

END OFiles.

