Accessing Files Programmer's Guide (32650-90885)

108 Chapter6
Closing a File
Closing a Magnetic Tape File
Note that a tape closed with the temporary no-rewind disposition is rewound and unloaded
if certain additional conditions are not met. It is possible for a single process to open a
magnetic tape device using the
device class option
of HPFOPEN/FOPEN, then again open
the already-allocated device by specifying its logical device number (ldev) using the
device
name option
of HPFOPEN/FOPEN. This may be done in such a manner that both magnetic
tape files are open concurrently. The second HPFOPEN/FOPEN does not require any operator
intervention to allocate the device. When file open and file close calls are arranged in a
nested fashion, tape files may be closed without deallocating the physical device, as
follows:
----
| HPFOPEN allocated tape
| ----
| | HPFOPEN
| | FCLOSE
| ----
| tape remains allocated
| ----
| | FOPEN
| | FCLOSE
| ----
| FCLOSE deallocated tape
----
Such nesting of HPFOPEN/FOPEN and FCLOSE pairs is required to keep from rewinding a tape
closed with FCLOSE. A tape closed with the temporary, no-rewind disposition is rewound
and unloaded unless the process closing it has another file currently open on the device.
When a temporary no-rewind tape is deallocated, the file system has not placed an EOF
(end-of-file mark) at the end of the data file.
The FCLOSE intrinsic can be used to maintain position when creating or reading a labeled
tape file that is part of a volume set. If you close the file with a disposition code of 0 or 3,
the tape does not rewind, but remains positioned at the next file. If you close the file with a
disposition code of 2, the tape rewinds to the beginning of the file, but is not unloaded. A
subsequent request to open the file does not reposition the tape if the sequence (
seq
)
subparameter is NEXT or default (1). A disposition code of 1 (save permanent) implies the
close of an entire tape volume set.