; Fixed bugs in error return handling in FindFirst and FindNext ; 02-17-87 T.A. Daneliuk ; ; ; Copyright (c) 1985 Martin Nohr and Tom Serface ; All Rights Reserved ; ;Revision Date Description ;-------- --------- -------------------------------------------- ; Interrupt and codes for the keyboard interface. DOSINT equ 21h ;call to ibm dos function cseg ; DOS 2.0 functions to find files given filespec the argument to ; FindFirst() is a pointer to a filespec containing d:\path\filespec ; and an integer permission attribute for the files to find. ; FindNext() simply continues and fills in the DTA area with the file ; matching the next pattern. FileFind.h must be included in any subroutines ; using these routines. ; In the calling program you would first call SetDta(&dataArea); ; and then call FindFirst(filespec,attr) finally subsequent calls to ; FindNext(attr) can be made. ; The filename and attributes can be read from dataArea. ;SetDta Set up DTA for Wild Card Conversions or whatever ; This version assumes that the Struct is in the ; programs DS. ; ; Call as SetDta(&dataArea) ; Where dataArea is struct *DTA dataArea ;void SetDta(); ;struct DTA dataArea; public SetDta_ SetDta_: push bp mov bp,sp mov dx,[bp+4] mov ah,1Ah ; set disk transfer address int DOSINT pop bp ret ;GetDta Get the current DTA segment and offset ; ; Call as GetDta(&segment,&offset) ; Where segment and offset are unsigned ; ;void GetDta(); ;unsigned segment, offset; public GetDta_ GetDta_: push bp mov bp,sp mov ah,2fh ; get disk transfer address int DOSINT mov ax,es mov si,[bp+4] mov word [si],ax mov si,[bp+6] mov word [si],bx pop bp ret ;RestDta Restore DTA Saved with GetDta ; ; Call as RestDta(segment,offset) ; Where segment and offset are unsigned ;void RestDta(); ;unsigned segment, offset; public RestDta_ RestDta_: push bp mov bp,sp push ds mov ds,[bp+4] mov dx,[bp+6] mov ah,1Ah ; set disk transfer address int DOSINT pop ds pop bp ret ;FindFirst Find the First File From a Wild Card Pattern ; ; Call as: FindFirst(filespec,attr) ; Where filespec is a char * ; and attr is an int attribute for the file ; 76543210 Bits ; 00000000 - Regular file ; 1 - Read Only ; 1 - Hidden ; 1 - System ; 1 - Volume Label ; 1 - Subdirectory ; 1 - Archive ; 1 - Unused ; 1 - Unused ; Returns 0 if no file found 1 if file is found ; ;int FindFirst(); ;char *filespec; ;int attr; public FindFirst_ FindFirst_: push bp mov bp,sp mov dx,[bp+4] ;pointer to filespec mov cx,[bp+6] ;attribute to search mov ah, 04eh int DOSINT and ax,ax ; 0 from DOS means file found - tad jnz no_mor inc ax ; found file so return 1 - tad jmp don no_mor: xor ax,ax ; no file found, return 0 - tad don: pop bp ret ;FindNext Find the Next File From a Wild Card Pattern ; ; Call as: FindNext(attr) ; Where: attr is an int attribute for the files ; to find. ; Returns 0 if no file found 1 if file is found ;int FindNext(); ;int attr; public FindNext_ FindNext_: push bp mov bp,sp mov cx,[bp+4] ;attribute mov ah, 04fH ;find next file in filespec int DOSINT and ax,ax ; 0 from DOS means file found - tad jnz no_more inc ax ; found file so return 1 - tad jmp done no_more: xor ax,ax ; no file found, return 0 - tad done: pop bp ret