Determining If a BFS File Exists
To determine if a BFS file exists and get the status of the file, you can use the DMSEXIFI or DMSEXIST routine. However, if you plan to read or write to the file and share the file with other users, you should not bother with determining if the file exists. You should begin file I/O by opening the file with an intent other than READ. This ensures that no other users could erase or revoke the file before you get a chance to open the file. Once you have the file opened, other users cannot erase the file.
DMSEXIFI returns file information in variables. If the file does not exist or you are not authorized to read from the directory, DMSEXIFI returns a return code of 8 and a reason code of 30000 or 44000. If the file does exist, DMSEXIFI returns a return code of 0 and places the file information in the variables that you provide. Check the authority information passed back to make sure you have the correct authority.
DMSEXIST returns file information in a specified buffer. If the file does not exist or you are not authorized to read from the directory, DMSEXIST returns a return code of 8 and a reason code of 90220. If the file does exist, DMSEXIST returns a return code of 0 and places the file information in the specified buffer. Check the authority information passed back to make sure you have the correct authority.
You can map the output with the EXSBUFF assembler mapping macro. For more information on EXSBUFF, see the z/VM: CMS Macros and Functions Reference.