next up previous top
Next: PipeType
Up: Property
Previous: MinConns

OpenMode

Description

The OpenMode property is used to further specify a SeqFile component in UniCon. It specifies Unix file options to be supplied when the associated sequential file in the implementation is opened in the file system. There are three options that can be specified: append, create, and truncate. These options correspond to the three Unix open mode flags O_APPEND, O_CREAT, and O_TRUNC.

A file opened with O_APPEND causes the current file offset to be initialized to the number of bytes from the beginning of the file. Normally, when a file is opened, the current offset is initialized to zero. Reading and writing normally start at the current file offset and the offset is incremented by the number of bytes read or written. A file opened with O_TRUNC causes the contents of the file to be deleted when it is opened. A file opened with O_CREAT is created if it does not exist in the file system at the time it is opened.

The OpenMode property can be specified in both a component instantiation and a component definition. The set of values for any OpenMode properties in a SeqFile component definition are merged with the values in the OpenMode properties in instantiations of the component. This merged set is then used as the set of open mode options for the file when it is opened in the system during execution.

Property Lists

The OpenMode property can legally be specified in the property list in the following
UniCon language elements:

Value Syntax

The syntax of the value part of the OpenMode property is one of the three keywords append, create, or truncate, optionally enclosed in double-quotes, surrounded by parentheses. The case of the letters can be upper, lower, or mixed.

Required Rule

Optional

There is no default value for the OpenMode property. If the property is not specified, none of the three open mode options are supplied as parameters during the open.

Merge Rule

MERGE

More than one specification of the OpenMode property in a single property list is treated as a single specification with the union of all values in all of the specifications.

Semantic Checks

The value part of the OpenMode property must be one of the three keywords append,
create, and truncate.

Example

The following is an example of a specification of an OpenMode property. It is embedded in the interface of a SeqFile component definition:

  COMPONENT Data_File
    INTERFACE IS
      TYPE SeqFile
      OPENMODE (create)
      RECORDFORMAT ("line")
      PLAYER Next_Line IS ReadNext
    END INTERFACE
    IMPLEMENTATION IS
      VARIANT Data_File IN "datafile"
        IMPLTYPE (Data)
      END Data_File
    END IMPLEMENTATION
  END Data_File
Below is another example of a specification of an OpenMode property. It is embedded in an instantiation of the above SeqFile component:

  USES My_Data_File INTERFACE Data_File
    OPENMODE (truncate)
  END My_Data_File
The OpenMode value for the My_Data_File SeqFile instantiation is create and truncate.


next up previous top
Next: PipeType
Up: Property
Previous: MinConns

Comments? Mail the current maintainer of this page.

Author: Gregory Zelesnik

Last Modified: May 12, 1996