(****
 *
 * Module File defines the objects and operations related to file processing
 * in the EClass system.
 *
 *)

module File;

  object File is
    components: name:FileName and permissions:FilePermissions and
        file_type:FileType and size:FileSize;
    description: (*
        A File has a name, permissions, type, and data.  These are the components 		sufficient to specify the behavior of EClass Tool file operations.
    *);
  end File;

  object FileName is string
    description: (*
        The name of a file.
    *);
  end;

  object FilePermissions is is_readable:IsReadable and is_writable:IsWritable
    description: (*
        FilePermissions indicate whether a file is readable and/or writable.
    *);
  end;

  object IsReadable is boolean
    description: (*
        Flag indicating whether a file is readable, which is required to be
        true by the FileOpen operation.
    *);
  end;

  object IsWritable is boolean
    description: (*
        Flag indicating whether a file is writable, which is required to be
        true by the FileSave operation.
    *);
  end;

  object FileType is eclass_type:EClassType or other_type:OtherType
    description: (*
        The type of file data is either EClassType data or any other
        type of data.
    *);
  end FileType;

  object EClassType
    description: (*
        File data typing tag indicating that a file contains eclass data
        created by the EClass Tool.
    *);
  end EClassType;

  object OtherType
    description: (*
        File data typing tag indicating that a file contains data other than
        eclass data created by the EClass Tool.
    *);
  end OtherType;

  object FileSize is integer
    description: (*
       The size in megabytes of a file.
    *);
  end FileSize;

  operation FileNew is
    inputs: nf:File;
    outputs: nf':File;

    description: (*
        Create a new EClass file.
    *);

  end FileNew;

  operation FileOpen is
    inputs: fn:FileName;
    outputs: nf':File;

    description: (*
        Open an existing EClass file of the given name.
    *);

  end FileOpen;

  operation FileClose is
    inputs: f:File;
    outputs: f':File;

    description: (*
        Close the current eclass if it does not require saving.
    *);

  end FileClose;

operation FileSave is
    inputs: f:File, fn:FileName;
    outputs: f':File;

    description: (*
        Saves the current file.
    *);

  end FileSave;

end File;