title 'ERAQ - Selective file erase' ; Supplied by NEC Information Systems Australia ; Extracted from SIG/M volume 43 ; ; Alterations by Kirk Lawrence (5/7/96): ; Added an assumed "*.*" if no command line parameter is entered. ; Customized the program for use on IBM-compatibles. ; Cleaned up the screen messages. ; (All added or altered code is indicated by "-KL") CR EQU 13 LF EQU 10 ESC EQU 27 TFCB EQU 5CH org 100h mov cl,9 ;function 9 - print string -KL mov dx,offset hdrmsg;point DX to header message -KL call bdos ;print it -KL mov si,81h ;location of the command line -KL parse: ;check command line for arguments -KL lodsb ;load a byte from the command line -KL cmp al,20h ;is it a space? -KL jg eraq ;no, so proceed -KL je parse ;yes, so go check the next byte -KL ; -KL ; This routine fills the file control block with question marks... -KL ; so if user hasn't entered a filespec, *.* is assumed. -KL ; -KL mov cx,11 ;length of FCB -KL mov si,tfcb + 1 ;location of FCB -KL mov dl,03Fh ;question mark into DL -KL agin: ; -KL mov [si],dl ;DL into memory location -KL inc si ;bump pointer -KL loop agin ;loop till CX=0 -KL ERAQ: mov dx,TFCB mov cl,17 ;Search first CALL BDOS cmp al,255 jnz FILFND mov dx,offset NFMSG call OUTBUF mov cl,0 jmp BDOS OUTBUF: mov cl,9 ;Print string jmp BDOS FILFND: mov bx,offset NAMBUF PUSH bx NXTFIL: mov cl,5 shl al,cl add al,81h mov ah,0 mov si,ax POP di mov cx,11 rep movs al,al PUSH di mov cl,18 ;Search next mov dx,tfcb CALL BDOS cmp al,255 jnz NXTFIL POP bx mov byte ptr [bx],80H ;End of list indicator mov bx,offset NAMBUF DELCHK: mov NBPOS,bx ;Output name mov cx,8 NXTCR2: mov al,[bx] AND al,7FH cmp al,' ' jz ENDNAM ;End of name PUSH bx PUSH cx CALL CONOUT POP cx POP bx INC bx loop NXTCR2 ENDNAM: mov ch,0 ADD bx,cx PUSH bx mov al,[bx] AND al,7FH cmp al,' ' jz ENDTYP ;No filetype mov al,'.' CALL CONOUT ;Output type mov cx,3 POP bx PUSH bx NXTCR3: mov al,[bx] AND al,7FH cmp al,' ' jz ENDTYP ;End of type PUSH bx PUSH cx CALL CONOUT POP cx POP bx INC bx loop NXTCR3 ENDTYP: mov dx,offset DFMSG1 ;Output rest of the message CALL OUTBUF POP bx test byte ptr [bx],80h jz NOTR_O ;Check for file R/O mov dx,offset DFMSG2 CALL OUTBUF NOTR_O: mov dx,offset DFMSG3 CALL OUTBUF mov cl,1 ;Console input CALL BDOS cmp al,ESC je quit ;-KL ; jnz $+3 -KL ; RET -KL AND al,5FH ;Convert lowercase to uppercase cmp al,'Y' jnz NXTCHK mov si,NBPOS mov di,TFCB+1 mov cx,11 rep movs al,al mov bx,TFCB+9 test byte ptr [bx],80h jz NTR_O and byte ptr [bx],7fh mov dx,TFCB mov cl,30 ;Set file attributes CALL BDOS NTR_O: mov dx,TFCB mov cl,19 ;Delete file CALL BDOS NXTCHK: mov al,CR CALL CONOUT mov al,LF CALL CONOUT mov bx,NBPOS add bx,11 test byte ptr [bx],80h mov cl,0 jnz bdos jmp DELCHK CONOUT: mov dl,al mov cl,2 ;Console output BDOS: push es int 224 pop es ret quit: ;-KL mov cl,9 ;-KL mov dx,offset nomore ;-KL call bdos ;-KL xor cx,cx ;-KL int 224 ;-KL hdrmsg db 27,'E',219,' ERAQ - Selective File Eraser',13,10 ;-KL db 219,13,10 ;-KL db 219,' Press Y to erase the file, N to NOT erase, ' ;-KL db 'ESC to quit.',13,10,10,10,'$' ;-KL NFMSG db 13,10,' =',16,' No matching files found.',07,13,10,'$' ;-KL DFMSG1 db ' exists$' ;-KL DFMSG2 db ', and is Read-Only$' ;-KL DFMSG3 db '. Erase (y/n)? $' ;-KL nomore db 'Quit',13,10,'$' ;-KL NBPOS dw 0 NAMBUF rs 64*64 db 0 END