File Sharing semantics
Section A.14 of the Ada Reference Manual allows implementations to provide a wide variety of behavior if an attempt is made to access the same external file with two or more internal files.
To provide a full range of functionality, while at the same time minimizing the problems of portability caused by this implementation dependence, GNAT handles file sharing as follows:
- In the absence of a shared=xxx form parameter, an attempt to open two or more files with the same full name is considered an error and is not supported. The exception Use_Error will be raised. Note that a file that is not explicitly closed by the program remains open until the program terminates.
- If the form parameter shared=no appears in the form string, the file can be opened or created with its own separate stream identifier, regardless of whether other files sharing the same external file are opened. The exact effect depends on how the C stream routines handle multiple accesses to the same external files using separate streams.
- If the form parameter shared=yes appears in the form string for each of two or more files opened using the same full name, the same stream is shared between these files, and the semantics are as described in Ada Reference Manual, Section A.14.
When a program that opens multiple files with the same name is ported from another Ada compiler to GNAT, the effect will be that Use_Error is raised.
The documentation of the original compiler and the documentation of the program should then be examined to determine if file sharing was expected, and shared=xxx parameters added to Open and Create calls as required.
Databases, Information Systems, and Peer-to-Peer Computing: First International Workshop, DBISP2P, Berlin Germany, September 7-8, 2003, Revised Papers (Lecture Notes in Computer Science)