(go to: table of contents, index, list of vms_lib, prev: DAY_OF_WEEK, next: DELETE_LOGICAL)
WARNING!Changes to the FAB can lead to crashes after returning
from the user-confirm-procedure back to LIB$DELETE_FILE !!
DELETE_FILE - Delete One or More Files
Format:
02-APR-1999 ZE.
status, context, resultant_name = vms_lib.delete_file ( \
filespec [,default-filespec] [,related-filespec] \
[,user-success-procedure] [,user-error-procedure] \
[,user-confirm-procedure] [,user-specified-argument] \
[,file-scan-context])
Returns:
Arguments:
Examples:
See the OpenVMS Record Management Services Reference Manual for information
about default file specifications.
See the OpenVMS Record Management Services Reference Manual for information
about related file specifications.
>>> import vms_lib
>>> import vms_sys
>>> # define user-procedures
>>> # user-success
>>> def u_success (filespec, user_arg):
... print '*user-success-procedure'
... print type(filespec), filespec
... print type(user_arg), user_arg
... return 1
... #-u_success
>>>
>>> # user-error
>>> def u_error (filespec, l_rms_sts, l_rms_stv, \
... l_error_source, user_arg):
... print '*user-error-procedure'
... print type(filespec), filespec
... print type(l_rms_sts), l_rms_sts
... print type(l_rms_stv), l_rms_stv
... print type(l_error_source), l_error_source
... print type(user_arg), user_arg
... return 1
... #-u_error
>>>
>>> # user-confirm
>>> def u_confirm (filespec, fab, user_arg):
... print '*user-confirm-procedure'
... print type(filespec), filespec
... print type(fab), fab
... print fab.FNA
... print type(user_arg), user_arg
... return 1
... #-u_confirm
>>>
>>> # simple delete-test
>>> file = open ('DELETE.TMP','w')
>>> file.close()
>>> vms_lib.delete_file ('delete.tmp;', None, None, \
... u_success, u_error, u_confirm, 'uspec-arg')
*user-confirm-procedure
<type 'string'> USER_HERE:[ZESSIN.DELETE]DELETE.TMP;1
<type 'vmsobj_fab'> <vmsobj_fab, FAB at 0x7fee81bc>
delete.tmp; <-- fab.FNA
<type 'string'> uspec-arg
*user-success-procedure
<type 'string'> USER_HERE:[ZESSIN.DELETE]DELETE.TMP;1
<type 'string'> uspec-arg
(1, 0, 'USER_HERE:[ZESSIN.DELETE]DELETE.TMP;1')
>>> # Note: 1 = status, 0 = context
>>> # see if file has been deleted ...
>>> import os; os.system ('DIRECTORY DELETE.TMP')
%DIRECT-W-NOFILES, no files found
98960 <-- return status from subprocess
>>>
>>> # try to delete an open file (triggers error-procedure)
>>> file = open ('DELETE.TMP','w')
>>> vms_lib.delete_file ('delete.tmp;', None, None, \
... u_success, u_error, u_confirm, 'uspec-arg')
*user-confirm-procedure
<type 'string'> USER_HERE:[ZESSIN.DELETE]DELETE.TMP;1
<type 'vmsobj_fab'> <vmsobj_fab, FAB at 0x7fee81bc>
delete.tmp; <-- fab.FNA
<type 'string'> uspec-arg
*user-error-procedure
<type 'string'> USER_HERE:[ZESSIN.DELETE]DELETE.TMP;1
<type 'int'> 98954 <-- rms_sts
<type 'int'> 2048 <-- rms_stv
<type 'int'> 1 <-- error-source, 1= error deleting file
<type 'string'> uspec-arg
(1409065, 0, 'USER_HERE:[ZESSIN.DELETE]DELETE.TMP;1')
>>> file.close()
>>>
>>> vms_sys.getmsg (98954) # rms_sts
('%RMS-E-FLK, file currently locked by another user', (0, 0, 0, 0))
>>> vms_sys.getmsg (2048) # rms_stv
('%SYSTEM-W-ACCONFLICT, file access conflict', (0, 0, 0, 0))
>>>
>>> vms_sys.getmsg (1409065)
('%LIB-S-ERRROUCAL, error routine called', (0, 0, 0, 0))
>>>
>>> # see if file has been deleted ...
>>> import os; os.system ('DIRECTORY DELETE.TMP')
Directory USER_HERE:[ZESSIN.DELETE]
DELETE.TMP;1
Total of 1 file.
1 <-- return status from subprocess
>>>
>>> # example of wildcard delete with context
>>> file = open ('DELETE1.TMP','w'); file.close()
>>> file = open ('DELETE2.TMP','w'); file.close()
>>> file = open ('DELETE3.TMP','w'); file.close()
>>> context = 0
... status, context, resultant_name = \
... vms_lib.delete_file ('delete*.tmp;', None, None, \
... u_success, u_error, u_confirm, 'uspec-arg', context)
... print status, context, resultant_name
*user-confirm-procedure
<type 'string'> USER_HERE:[ZESSIN.DELETE]DELETE1.TMP;1
<type 'vmsobj_fab'> <vmsobj_fab, FAB at 0x7fee81bc>
delete*.tmp;
<type 'string'> uspec-arg
*user-success-procedure
<type 'string'> USER_HERE:[ZESSIN.DELETE]DELETE1.TMP;1
<type 'string'> uspec-arg
*user-confirm-procedure
<type 'string'> USER_HERE:[ZESSIN.DELETE]DELETE2.TMP;1
<type 'vmsobj_fab'> <vmsobj_fab, FAB at 0x7fee81bc>
delete*.tmp;
<type 'string'> uspec-arg
*user-success-procedure
<type 'string'> USER_HERE:[ZESSIN.DELETE]DELETE2.TMP;1
<type 'string'> uspec-arg
*user-confirm-procedure
<type 'string'> USER_HERE:[ZESSIN.DELETE]DELETE3.TMP;1
<type 'vmsobj_fab'> <vmsobj_fab, FAB at 0x7fee81bc>
delete*.tmp;
<type 'string'> uspec-arg
*user-success-procedure
<type 'string'> USER_HERE:[ZESSIN.DELETE]DELETE3.TMP;1
<type 'string'> uspec-arg
>>> print status, context, resultant_name
1 2281736 USER_HERE:[ZESSIN.DELETE]DELETE3.TMP;1
>>>
@@ more DELETE_FILE examples
>>>
(go to: table of contents,
index,
list of vms_lib,
prev: DAY_OF_WEEK,
next: DELETE_LOGICAL)