![]() |
Section 8.10.1.4: |
![]() |
This abstract class defines a state component which is a set of all instantiations of objects of any class sub-typing from this class in addition to the vdm model types used wherever this class name is used. Note that SAME has to be an instantiated class, not an abstract one.
NOTE | See the important note about vdm state in the notes on vdm-sl usage in this specification. |
This abstraction models the conventional notion of a file as a sequence of objects stored in the environment in which th program is executing. This abstraction could be extended to consider any named external entity which has a similar uniform interface to the program.
Compared with most Sather required library classes, the group of file opening/creating features which follow are tightly constrained by the state of the environment at the time the program executes. There are a number of general conditions which are pre-requisite to them all but which are not amenable to the use of formal specification tools. These are :-
This feature opens an existing file for reading - providing all of the general pre-requisites have been met. The notional file pointer is positioned at the beginning of the file.
open_for_read | ( |
name : STR | |
) : SAME |
The general pre-conditions given should be satisfied for successful operation - but are necessarily tested during execution - in addition to the one given below.
Providing all general pre-conditions are satisfied then a new connection to the named file is returned.
Providing that the file access permission criteria for opening the file for reading are met the file object will be returned with the file pointer set to the beginning of the file, otherwise void is returned.
This feature opens an existing file for writing - providing all of the general pre-requisites have been met. The notional file pointer is positioned at the beginning of the file ready for writing. Note that any existing contents is lost.
open_for_write | ( |
name : STR | |
) : SAME |
The general pre-conditions given should be satisfied for successful operation - but are necessarily tested during execution - in addition to the one given below.
This feature determines if the file with the given name exists and attempts to open it if it does exist providing that the file access permission criteria for opening the file for writing are met. If these necessarily dynamic checks are met then a connection to the file object will be returned with the file pointer set to the beginning of the file ready for writing only, otherwise void is returned.
This feature opens an existing file for writing - providing file access criteria are met. The notional file pointer is positioned at the end of the current file contents ready for writing. Note that any existing contents are inaccessible.
open_at_end | ( |
name : STR | |
) : SAME |
The general pre-conditions given should be satisfied for successful operation - but are necessarily tested during execution - in addition to the one given below.
Providing that file access permission criteria for opening the file for appending are met the file object will be returned with the file pointer set to the end of the file ready for writing only, otherwise void is returned.
This feature opens an existing file for update - providing all of the general pre-requisites have been met. The notional file pointer is positioned at the beginning of the file.
open_for_update | ( |
name : STR | |
) : SAME |
The general pre-conditions given should be satisfied for successful operation - but are necessarily tested during execution - in addition to the one given below.
Providing that file access permission criteria for opening the file for both reading and writing are met the routine returns the file object desired with the file pointer indicateing the beginning of the file, otherwise void is returned. Reading and writing of any part of the file may be undertaken in any desired sequence.
This feature opens an existing file with the notional file pointer at the end for update - providing all of the general pre-requisites have been met.
open_at_end_for_update | ( |
name : STR | |
) : SAME |
The general pre-conditions given should be satisfied for successful operation - but are necessarily tested during execution - in addition to the one given below.
Providing that file access permission criteria for opening the file for reading and writing are met then the file object will be returned with the file pointer set to the end of the file, otherwise void is returned. After an initial write reading and writing of any part of the file may be undertaken in any desired sequence.
This feature creates a new file with the notional file pointer at the beginning for writing only - providing all of the general pre-requisites have been met.
create_for_write | ( |
name : STR | |
) : SAME |
The general pre-conditions given should be satisfied for successful operation - but are necessarily tested during execution - in addition to the one given below.
Providing all general pre-conditions are satisfied then a new empty file is created and a connection to it returned.
Providing that no environment detected errors occur the feature returns the new file object with the file pointer set to the beginning of the file for writing only, otherwise void is returned.
This feature creates a new file with the notional file pointer at the beginning for writing and reading - providing all of the general pre-requisites have been met.
create_for_update | ( |
name : STR | |
) : SAME |
The general pre-conditions given should be satisfied for successful operation - but are necessarily tested during execution - in addition to the one given below.
provided that no environment detected error is encountered then this feature returns a new file object with the file pointer set to the beginning of the file for writing. Writing and reading may be carried out in any order.
This feature creates a new temporary file with the notional file pointer at the beginning for writing and reading - providing all of the general pre-requisites have been met. When closed the file, being temporary, will no longer exist.
create_temp | : SAME |
The only general pre-condition which need be met is the ability to create a temporary directory somewhere.
Providing that the creatioin pre-conditioin is satisfied thena new temporary file will be created and a connection to it will be returned with the file pointer set to the beginning of the file for writing, otherwise void is returned. Writing and reading may be carried out in any order.
This feature is provided to close the connection to the underlying file storage object.
This feature closes the connection to the external file and invalidates this object for further file access.
This predicate returns true if and only if the file is readable.
Since this routine is a predicate, the pre-condition is vacuously true.
Since this routine is a predicate, the post-condition is also vacuously true.
This feature returns true if and only if the file is both open and readable, otherwise false.
This predicate returns true if and only if the file is writable.
Since this routine is a predicate, the pre-condition is vacuously true.
Since this routine is a predicate, the post-condition is also vacuously true.
This feature returns true if and only if the file is both open and writable, otherwise false.
This predicate returns true if and only if the file connected has not been closed.
Since this routine is a predicate, the pre-condition is vacuously true.
Since this routine is a predicate, the post-condition is also vacuously true.
This feature returns true if and only if the file has not been closed.
This predicate returns true if and only if the file is both open for update and has not been closed.
Since this routine is a predicate, the pre-condition is vacuously true.
Since this routine is a predicate, the post-condition is also vacuously true.
This feature returns true if and only if the file has not been closed and is open for update, otherwise false.
This routine returns the current position of the notional file pointer. Note that it is not possible to set this value unless a object is being used!
This routine returns the current position of a notional file cursor providing that the file is open, otherwise if some error occurred in the execution environment then the value CARD::maxval.
This feature provides the current size of the file. Note that a file opened for reading only will always have the same size.
This routine returns the current size of the file. Note that this may not reflect the current file stored in the environment's actual size, since this depends on whether current contents have been flushed.
This predicate may be used to determine whether there has been a problem relating to the file connection.
Since this routine is a predicate, the pre-condition is vacuously true.
Since this routine is a predicate, the post-condition is also vacuously true.
This feature provides an indication whether some error in the program environment has affected the behaviour of the file since either creation or the most recent use of the clear feature defined below.
This feature provides a program environment dependent string indicating the nature of any error which may have been detected. Note that the message only refers to the latest error (if any) in an environment-defined manner.
This feature provides an environment defpendent message describing the most recent error in the program environment which has affected the behaviour of the file connection since opening/creation or the most recent use of the clear feature defined below.
This feature clears any error which may have occurred in the underlying file system in relation to the file.
This feature provides a way of clearing any error which may have occurred in relation to the file.
![]() |
Language Index | ![]() |
Library Index | ![]() |
Input/Output Index |
Comments or enquiries should be made to
Keith
Hopper. Page last modified: Friday, 17 November 2000. |
![]() |