Accessing Files Programmer's Guide (32650-90885)

103
6 Closing a File
Once your program is finished accessing a file, the program can terminate access to the file
with the FCLOSE intrinsic. This chapter discusses various ways that you can use the
FCLOSE intrinsic to close disk files and device files. Examples are provided to illustrate
important features available through the FCLOSE intrinsic. The following subjects are
discussed in detail:
how the file system closes a file
closing a disk file
closing a magnetic tape file
How the File System Closes a File
You terminate access to a file from your program with the FCLOSE intrinsic. The FCLOSE
intrinsic applies to both disk and device files. FCLOSE also deallocates the device on which
the file resides; however, if your program has several concurrent HPFOPEN/FOPEN calls
issued to the same file, the device is not deallocated until the last "nested" FCLOSE intrinsic
is executed.
You can use the FCLOSE intrinsic to specify (or change) the disposition of a disk or a
magnetic tape file when it is closed. The disposition of a disk or magnetic tape file can be
new, temporary, or permanent. If you do not change the disposition of a new file when it is
closed, the file and its contents are deleted from the system when the file is closed using
FCLOSE.
You can change the disposition of a new file to be either temporary or permanent. A file
closed with a temporary disposition is closed as a temporary file. It is deleted from the
system when your job/session is terminated. A file closed with a permanent disposition is
closed and saved as a permanent file. It remains in the system domain after your
job/session ends, and until you purge it.
When you close a file with either a temporary or permanent disposition, MPE/iX conducts
a search:
If the file is to be closed as a temporary file, the job file domain is searched.
If the file is to be closed as a permanent file, the system file domain is searched.
You are not allowed to have duplicate file names in the same domain. If MPE/iX finds a file
of the same name in the searched directory, the file is not closed, and the FCLOSE intrinsic
returns an error condition.