FSOPEN
FSOPEN supports an OPENTYP option which describes the type of input/output activity to be performed: READ, WRITE, NEW, REPLACE. The OPENTYP option applies to files on minidisks and SFS files.
For SFS files, the OPENTYP option is useful as follows:
- It assures that the file is not already open with the file system macro interface.
- It allows the user to specify the type of operation to be performed on the file. This allows the file system to properly open and lock the file to safely allow multiple concurrent access to the file, and provide the user with a consistent image of the file from open to close. Without the OPENTYP parameter, the FSOPEN macro only performs an existence check (equivalent to FSSTATE), and does not actually open and lock the file, which could result in a change to the file by another user between the FSOPEN and the first FSREAD, FSWRITE, or FSPOINT to the file.
- For output files, the OPENTYP=REPLACE option lets the file be replaced without loss of authorities and aliases. Prior to VM/SP Release 6, a file would typically be erased and rewritten to replace it. For more information on replacing shared files, see Replacing Shared Files. In the Shared File System, erasing a file causes all authorities and aliases to the file to be lost. (Note that authorities are lost only on files in file control directories—authorizations cannot be granted on individual files within directory control directories.)
- For OPENTYP=READ, it prevents subsequent writes to the file.
- For OPENTYP=NEW, WRITE, or REPLACE, it assures that the file is on a directory accessed R/W.
For minidisk files, the OPENTYP option is useful as follows:
- It assures that the file is not already open.
- For OPENTYP=REPLACE, it erases the file at open time, making it unnecessary for the application program to do so.
- For OPENTYP=READ, it prevents subsequent writes to the file.
- For OPENTYP=NEW, WRITE, or REPLACE, it assures that the file is on a minidisk accessed R/W.