When a program opens a NEW disc ￿le with an HPFOPEN or FOPEN call, the File System does not search to determine if a ￿le of the same name exists. This occurs when y ou attempt to save a ￿le with the FCLOSE intrinsic.

When a program opens a disc ￿le speci￿ed as a NEW ￿le in the option of an HPFOPEN or FOPEN call that determines the domain, and sa ves it with the FCLOSE intrinsic, the MPE/iX File System conducts a searc h. If the ￿le is to be sa ved as a TEMP ￿le, it searches the Job Temporary File Directory . If the ￿le is to be sa ved as a PERMANENT ￿le, it searches the System Permanent File Directory . If the File System ￿nds a ￿le of the same name in a directory it searches, it returns an error code to y our program. Th us, you can open a NEW ￿le with the same name as an existing ￿le, but an error occurs if an FCLOSE intrinsic attempts to sa ve it in the same domain with a ￿le of the same name.

Similarly, when a program opens a disc ￿le speci￿ed as a TEMP ￿le in the domain option of an HPFOPEN or FOPEN call and saves it with the FCLOSE intrinsic, only the Job T emporary File Directory (not the System File Directory) is searc hed. Thus it is possible to ha ve three ￿les with the same name, a PERMANENT ￿le, a NEW ￿le, and a TEMP ￿le. If a ￿le opened as TEMP is closed and sa ved as a PERMANENT ￿le with the FCLOSE intrinsic, MPE/iX searc hes the System Permanent File Directory . If it ￿nds a ￿le of the same name, it returns an error code to the program.

If a program opens a disc ￿le speci￿ed as OLD in the domain option of an HPFOPEN or FOPEN call and saves it with the FCLOSE intrinsic, the File System searc hes the Job Temporary File Directory and the System P ermanent File Directory to determine if a ￿le of the same name already exists. If it ￿nds a ￿le of the same name in either directory , it returns an error code to your program.

If your program does not issue an FCLOSE intrinsic call on ￿les that ha ve been opened, MPE/iX closes all ￿les automatically when the program's process terminates. In this case, MPE/iX closes all opened ￿les with the same disposition they had before being opened. NEW ￿les are deleted, OLD ￿les are saved and assigned to the domain in whic h they previously belonged, either PERMANENT or TEMP. This can be altered with a :FILE command.

For examples of closing a new ￿le as either a TEMP or a PERMANENT ￿le, refer to Accessing Files Programmer's Guide (32650-90017). Figure 6-9 sho ws the directories searc hed for ￿le names when a ￿le is opened and closed, depending on the ￿le domain.

6-18 File System