; ; 27-AUG-1984 ms-dos 2.xx dir search function library. ; for Computer Innovations C86 v2.10E ; ; Copyright (C) by Bob Green 27-AUG-1984 ; All Rights Reserved. Released For Any use ; without cost exceeding the cost of handling ; and reproduction, as long this heading is ; included with all or any part used of this ; program and credit given to Bob Green. ; ; ;found= _xfind(pathname,filename,&fsize,attrib,flag); ;int found,flag,attrib; ;char *pathname,filename[14]; ;long fsize; ; ;Search for the specified pathname. flag should ;be 0 for the first call, non-zero for all ;subsequent calls. _xfind() returns true if a ;match was found, and the found file is ;returned in filename[], in ASCIZ format. ;Attrib is the DOS attributes to match; I ;will not describe that mess here. _xfind() ;returns the size of the file in fsize. (Don't ;forget to pass the address of fsize.) ; For example: ; ;int i; ;char filename[14]; ;long fsize; ; ; i= 0; ; while (_xfind("\\bin\\*.*",filename,&fsize,0,i)) { ; printf("File: %14s Size: %lu\n",filename,fsize); ; ++i; ; } ; printf("%u matching files.\n",i); ; ;Prints the names of all matching disk files. ;Any other calls (except_fsize()) can be made ;in between calls to _xfind(). ;; ;; ret= xfind(path,name,size,attrib,first) ;; int ret; 0 if no match ;; char *path; ;; char *name; dest name, ;; long *size; ptr to file siz ;; int attrib; attributes ;; int first; 0 if 1st time, ;; ;;Find the Nth occurence of pathname. Returns ;;0 when no match. Only the filename portion ;;can contain wildcards. The returned filename ;;does not contain the path portion of the ;;input string. ;; Not recursive. Do not call _FSIZE ;;inbetween _XFIND calls. ;; ; ;fsize= _fsize(pathname); ;long fsize; ; ; Returns the size of the file in bytes. ;Returns 0 if no file. Do NOT call inbetween ;calls to _xfind(). ; ; xstat(); ;Return a pointer to a block of info on a ;file. Just returns a pointer to the local ;data block. ; ; prologue.h 11/5/83 ; standard prologue for c86 assembly code ; DEFINE ARGUMENT BASE RELATIVE FROM BP @AB EQU 4 @CODE SEGMENT BYTE PUBLIC 'CODE' @CODE ENDS @DATAB SEGMENT PARA PUBLIC 'DATAB' @DATAB ENDS @DATAC SEGMENT BYTE PUBLIC 'DATAC' @sb label byte @sw label word @DATAC ENDS @DATAI SEGMENT BYTE PUBLIC 'DATAI' @ib label byte @iw label word @DATAI ENDS @DATAT SEGMENT BYTE PUBLIC 'DATAT' @DATAT ENDS @DATAU SEGMENT BYTE PUBLIC 'DATAU' @ub label byte @uw label word public _xstat public _xfind public _fsize xfbuf db (?) ;search attrib db (?) ;drive, db 11 dup (?) ;name, dw (?) ;last ent dd (?) ;DPB, dw (?) ;dir start db (?) ;attrib found, dw (?) ;time? dw (?) ;date? fsize dw (?) ;size low dw (?) ;size hi, fname db 13 dup (?) ;packed name, @DATAU ENDS @DATAV SEGMENT BYTE PUBLIC 'DATAV' @DATAV ENDS DGROUP GROUP @DATAB,@DATAC,@DATAI,@DATAT,@DATAU,@DATAV @CODE SEGMENT BYTE PUBLIC 'CODE' ASSUME CS:@CODE,DS:DGROUP ; END OF PROLOGUE.h xfpath equ 4 ;path pointer, xfname equ 6 ;retnd name, xfsize equ 8 ;file size ptr, xfaccess equ 10 ;access, xfflag equ 12 ;first time flag, _xfind proc near push bp mov bp,sp mov ah,26 ;set DMA addr mov dx,offset dgroup:xfbuf int 21h ;to buffer, test word ptr [bp+xfflag],-1 mov ah,78 ;do right call, jz xf1 mov ah,79 ;0 == 1st time, xf1: mov dx,[bp+xfpath] ;path name, mov cx,[bp+xfaccess];access, int 21h mov ax,0 ;ret if no jc xfr ;match, ; ;Copy the file size in. ; mov bx,[bp+xfsize] ;size ptr, mov ax,fsize mov [bx],ax mov ax,fsize+2 mov [bx+2],ax mov di,[bp+xfname] ;dest string, mov si,offset dgroup:fname mov cx,12 cld ; ;Fix a "slight" XENIX bug: Delete trailing ;spaces, else it fails OPENs. ; xf2: lodsb ;get a byte, cmp al,0 ;if null je xf3 cmp al,' ' ;or space, je xf3 ;stop, stosb loop xf2 ;max 11 chars xf3: mov byte ptr [di],0 ;terminate, mov ax,1 ;good return. xfr: pop bp ret _xfind endp page _fsize proc near push bp mov bp,sp mov ah,26 ;set DMA addr mov dx,offset dgroup:xfbuf int 21h ;to buffer, mov ah,78 ;search 1st, xs1: mov dx,[bp+4] ;path name, mov cx,0 int 21h mov ax,0 ;ret if no mov bx,0 ;match, jc xsr mov bx,fsize mov ax,fsize+2 xsr: pop bp ret _fsize endp page ; ;Return a pointer to a block of info on a ;file. Just returns a pointer to the local ;data block. ; _xstat proc near mov ax,offset dgroup:xfbuf ret _xstat endp include epilogue.h end