include	clib.inc
include	dos.inc
include	confirm.inc

ID_DELETE	= 1	; return 1
ID_DELETEALL	= 2	; return 1 + update confirmflag
ID_SKIPFILE	= 3	; return 0
ID_CANCEL	= 0	; return -1

_TEXT	SEGMENT

confirm_delete_file proc dist pascal public uses si fname:dword, flag:word
	mov ax,flag
	mov dx,confirmflag
	.if al & _A_RDONLY && dl & CFREADONY
	    mov ax,-1
	    mov si,not (CFREADONY or CFDELETEALL)
	.elseif al & _A_SYSTEM && dl & CFSYSTEM
	    mov ax,-2
	    mov si,not (CFSYSTEM or CFDELETEALL)
	.elseif dl & CFDELETEALL
	    xor ax,ax
	    mov si,not CFDELETEALL
	.else
	    mov ax,1
	    jmp @F
	.endif
	invoke confirm_delete, fname, ax
	.if ax == ID_DELETEALL
	    and confirmflag,si
	    mov ax,1
	.elseif ax == ID_SKIPFILE
	    xor ax,ax
	.elseif ax != ID_DELETE
	    mov ax,-1
	.endif
      @@:
	ret
confirm_delete_file endp

_TEXT	ENDS

	END
