[net.sources] OSSI: SIFiles

biagioni@unc.UUCP (Edoardo Biagioni) (11/06/86)

(***************************************************************************)
(***                                                                     ***)
(***                                                                     ***)
(***                      O  S  S  I                                     ***)
(***                      ==========                                     ***)
(***                                                                     ***)
(**)               DEFINITION MODULE SIFiles;                            (**)
(***               =========================                             ***)
(***                                                                     ***)
(***   This module supports operations on files.                         ***)
(***                                                                     ***)
(***---------------------------------------------------------------------***)
(***                                                                     ***)
(***   Hardware:             independent                                 ***)
(***   Operating System:     independent                                 ***)
(***   Compiler:             independent                                 ***)
(***                                                                     ***)
(***   Version:      3.0                                                 ***)
(***   Implemented:  see copyright                                       ***)
(***   Date:         1986-03-12                                          ***)
(***                                                                     ***)
(***---------------------------------------------------------------------***)
(***                                                                     ***)
(***   Copyright 1984, 1985, 1986 by                                     ***)
(***      E. S. Biagioni                                                 ***)
(***      G. Heiser                                                      ***)
(***      K. Hinrichs                                                    ***)
(***      C. Muller                                                      ***)
(***                                                                     ***)
(***   Institut fuer Informatik                                          ***)
(***   ETH Zuerich                                                       ***)
(***   CH 8092 Zuerich                                                   ***)
(***   Switzerland                                                       ***)
(***                                                                     ***)
(***   Department of Computer Science                                    ***)
(***   University of North Carolina                                      ***)
(***   Chapel Hill, North Carolina 27514                                 ***)
(***   U.S.A.                                                            ***)
(***                                                                     ***)
(*** Permission to copy without fee all of this material is granted      ***)
(*** provided that the copies are not made or distributed for direct     ***)
(*** commercial advantage, that this OSSI copyright notice is            ***)
(*** included in the copy, that the module is not modified in any way    ***)
(*** except where necessary for compilation on a particular system,      ***)
(*** and that the module is always distributed in its original form.     ***)
(*** Distribution of this module in a modified form without including    ***)
(*** the original version is a violation of this copyright notice.       ***)
(***                                                                     ***)
(***---------------------------------------------------------------------***)
(***                                                                     ***)
(***   Updates:                                                          ***)
(***                                                                     ***)
(***                                                                     ***)
(***************************************************************************)

(* This module allows to manipulate whole files.
   Files may be deleted using the procedure DeleteFile and their names can
   be changed using RenameFile. Existence of a file may be inquired using
   FileExists. CopyFile generates a copy of an existing file.
   SearchFile allows expansion of logical names.

   Logical name expansion is done by means of 'domains'. A domain can be
   thought of as a table of logical name/file name pairs. There always exist
   the (possibly empty) domains 'SYSTEM' and 'USER'. The former specifies
   system-wide, the latter user-specific but application independend
   definitions. In addition to these, there are zero or more application
   specific domains. These are defined external to OSSI for use by
   OSSI-based programs.

   Success or failure of an operation is indicated by a variable 'result'.
   After a successful operation, 'result' will be equal to 'done',
   after an unsuccessful operation its value will be different from
   'done'. The possible result values are system dependent and the
   error message corresponding to a particular value can be obtained by a
   call to 'Message'. *)

FROM SISystem IMPORT
   SIResult;


EXPORT QUALIFIED
   FileExists,
   RenameFile,
   DeleteFile,
   CopyFile,
   SearchFile;


PROCEDURE FileExists (fileName: ARRAY OF CHAR): BOOLEAN;
(* Returns whether the file with the given name exists.
   'fileName' must be a fully specified file name.
   The result is undefined if 'fileName' designates a newly created
   file that has not yet been closed. *)

PROCEDURE DeleteFile (fileName: ARRAY OF CHAR; VAR result: SIResult);
(* The file named 'fileName' is deleted. After successful completion
   FileExists (FileName) will return FALSE.
   FileName must be a fully specified file name.
   The operation will fail if 'fileName' does not designate an
   existing file, or if deletion is not possible (e.g. due to access
   rights violation).
   An unsuccessful copy operation will leave the file unchanged. *)

PROCEDURE RenameFile (oldFileName,
                      newFileName:  ARRAY OF CHAR;
                      VAR result:   SIResult);
(* The name of 'oldFileName' is changed to 'newFileName', both names
   must be fully specified file names.
   The operation will fail if 'oldFileName' does not designate an
   existing file, or if 'newFileName' designates a pre-existing file,
   or if renaming is not possible (e.g. different devices).
   An unsuccessful rename operation will leave both files unchanged. *)

PROCEDURE CopyFile (oldFileName,
                    newFileName:  ARRAY OF CHAR;
                    VAR result:   SIResult);
(* The file 'oldFileName' is copied onto 'newFileName'.
   The operation may fail due to one of the following reasons:
    - 'oldFileName' is not a valid filename or the designated file
      cannot be accessed or read.
    - 'newFileName' is not a valid filename or the designated file
      cannot be created.
    - space for the new file is not available.
   An unsuccessful copy operation will leave both files unchanged. *)

PROCEDURE SearchFile (domain,
                      logicalName: ARRAY OF CHAR;
                      VAR fileName: ARRAY OF CHAR;
                      VAR result:   SIResult);
(* The table 'domain' is used to expand 'logicalName' to yield
   'fileName'.
   The operation will fail if 'domain' does not exist or is
   empty, or if no valid filename can be build from 'logicalName' 
   using the information of 'domain'. *)

END SIFiles.