Erasing Files

Use the DMSERASE routine to delete a minidisk file, Shared File System base file, alias, external object, or directory; or to delete the data in an SFS file. For example, to delete the file GETRID OFITNOW in the POOLA:JOHN.TEST directory, use the following REXX statements:
fileid.fname = 'GETRID'
fileid.ftype = 'OFITNOW'
fileid.dirname = 'POOLA:JOHN.TEST.'
fileid = fileid.fname fileid.ftype fileid.dirname
fileidlen = length(fileid)
options='COMMIT ENTIRE'
optlen=length(options)
 
call csl 'DMSERASE retcode reascode fileid fileidlen options',
         'optlen'
 
exit
The authorities that you have to a file and a directory affect whether you can use the ENTIRE and DATAONLY options to erase another user's files and aliases. This table summarizes the interactions for both files and aliases:
Table 1. Using the DMSERASE routine with the ENTIRE and DATAONLY options
Call DMSERASE against Option Necessary authorities Results
File write Directory write File read
File in file control directory ENTIRE   File and all related authorizations, aliases, and control data are erased.
File in file control directory DATAONLY     Only contents of file are deleted; aliases, authorizations, control data, and empty file remain.
Alias ENTIRE   Alias is deleted; base file is unaffected.
Alias DATAONLY     Contents of base file are deleted.
File in directory control directory ENTIRE     File and all related authorizations, aliases, and control data are erased.
File in directory control directory DATAONLY     Only contents of file are deleted; aliases, authorizations, control data, and empty file remain.
You cannot erase a file under the following conditions:
  • You have the file open
  • The file is locked by another user
  • You are not authorized to the file or directory
  • Any user (including the issuer of your program) has a SHARE lock on the file.
If the issuer of your program has an UPDATE or EXCLUSIVE lock on a file, the file can be erased.

For more information on aliases and sharing files, see SFS File Sharing. For more information on locks for files and directories, see Locking SFS Files and Directories.