home *** CD-ROM | disk | FTP | other *** search
- page 58,132
-
- ; dossrch.asm
- ; contains: dossrch()
- ;
-
- include model.h
- include prologue.h
- include equ.h
- name dossrch
- dseg dossearch
-
- ;==>-- dossrch() static data area
- ;
- fffndta db 21 dup(?) ;reserved
- xattr db 1 dup(?) ;attribute byte
- xfiltim dw 1 dup(?) ;Files time
- xfildat dw 1 dup(?) ;Files date
- xfilsiz dd 1 dup(?) ;Files size
- xnamext db 13 dup(?) ;null terminated name & extension of file name
- svdtaof dw 1 dup(?) ;saved dta offset
- svdtasg dw 1 dup(?) ;saved dta segment
-
- endds
-
- pseg dossearch
-
- ;==>-- int dossrch(searchname,searchattribute,filename,filetimedate,
- ; filesize,fileattr)
- ;
- ;; ARGUMENTS:
- ; (char *) searchname - points to string to do find
- ; first for, if NULL does find
- ; next.
- ; (int) searchattribute - attribute to use for when
- ; searching
- ; (char *) filename - pointer to string to receive
- ; filename
- ; (struct TIMEDATE *) filetimedate - pointer to TIMEDATE structure
- ; that receives files time/date
- ; information.
- ; (long *) filesize - pointer to long that receives
- ; files size
- ; (unsigned *) fileattr - pointer to unsigned (16bit)
- ; value that receives files
- ; attribute.
- ; Note: filename or filetimedate or filesize or fileattr can be
- ; NULL pointers if you do not want any of the information returned.
- ;
- ;; DESCRIPTION:
- ; This function does search first/search next returning information
- ; via pointers passed to the function as parameters.
- ;
- ;; RETURNS:
- ; 00 if successful or dos error code.
- ;
- ;; AUTHOR:
- ; "" 27-MAR-1987 16:21:33.38
- ; Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- ;;;
- cproc dossrch
- push es
- mov ah,2fh
- int 21h
- mov svdtaof,bx ;save current in variables
- mov svdtasg,es
- lea dx,fffndta ;and point it to our data area
- mov ah,1ah
- int 21h
- if _LDATA
- push ds
- lds dx,dword ptr @ab[bp]
- mov cx,@ab+4[bp]
- mov ax,ds ;check for null
- or ax,dx
- mov ah,4fh ;assume find next needed
- jz donext ;check assumption
- dec ah ;else do find first (4E)
- donext: int 21h
- pop ds ;restore ds
- jnc srok
- jmp srchex ;if error leave with it
- srok: cld
- les di,dword ptr @ab+6[bp] ;see if he wants file name
- mov ax,es
- or ax,di ;if == NULL, skip output
- jz ckftim ;and check file time
- lea si,xnamext ;si=source
- cld ;do auto increment
- dfslop: lodsb ;read ds:si to al & ++si
- stosb ;store al to es:di & ++di
- or al,al ;copy till AFTER null has been copied
- jnz dfslop
- ckftim: les di,dword ptr @ab+0ah[bp] ;see if he wants time/date
- mov ax,es
- or ax,di ;if==NULL, skip output
- jz ckfsiz ;and check file date
- mov ax,xfildat ;date to ax
- mov bx,ax ;save here
- mov cl,9 ;shift to year
- shr ax,cl
- and ax,7fh ;mask all but year
- add ax,1980 ;adjust year
- stosw ;and save in structure
- mov ax,bx ;refresh
- mov cl,5
- shr ax,cl
- and ax,0fh
- stosw
- mov ax,bx ;now do day
- and ax,1fh
- stosw
- mov ax,xfiltim ;get time
- mov cl,11
- mov bx,ax
- shr ax,cl
- and ax,1fh
- stosw ;save hours
- mov ax,bx
- mov cl,5
- shr ax,cl ;shift down minutes
- and ax,3fh
- stosw ;save minutes
- mov ax,bx
- and ax,1fh
- shl ax,1 ;*2
- stosw ;save seconds
- xor ax,ax ;save hundredths = 0
- stosw
- ckfsiz: les di,dword ptr @ab+0eh[bp] ;see if he wants size
- mov ax,es
- or ax,di ;if==NULL, skip output
- jz ckfatr ;and check file attribute
- lea si,xfilsiz
- lodsw
- stosw
- lodsw
- stosw
- ckfatr: les di,dword ptr @ab+12h[bp] ;see if he wants attribute
- mov ax,es
- or ax,di ;if==NULL, skip output
- jz srchex ;and exit
- mov al,xattr
- xor ah,ah
- stosw
-
- else
-
- mov dx,@ab[bp]
- mov cx,@ab+2[bp]
- or dx,dx ;check for null
- mov ah,4fh ;assume find next needed
- jz donext ;check assumption
- dec ah ;else do find first (4E)
- donext: int 21h
- jnc srok
- jmp srchex ;if error leave with it
- srok: cld
- mov ax,ds
- mov es,ax ;es=ds
- mov di,@ab+4[bp] ;see if he wants file name
- or di,di ;if == NULL, skip output
- jz ckftim ;and check file time
- lea si,xnamext ;si=source
- cld ;do auto increment
- dfslop: lodsb ;read ds:si to al & ++si
- stosb ;store al to es:di & ++di
- or al,al ;copy till AFTER null has been copied
- jnz dfslop
- ckftim: mov di,@ab+6[bp] ;see if he wants time/date
- or di,di ;if==NULL, skip output
- jz ckfsiz ;and check file size
- mov ax,xfildat ;date to ax
- mov bx,ax ;save here
- mov cl,9 ;shift to year
- shr ax,cl
- and ax,7fh ;mask all but year
- add ax,1980 ;adjust year
- stosw ;and save in structure
- mov ax,bx ;refresh
- mov cl,5
- shr ax,cl
- and ax,0fh
- stosw
- mov ax,bx ;now do day
- and ax,1fh
- stosw
- mov ax,xfiltim ;get time
- mov cl,11
- mov bx,ax
- shr ax,cl
- and ax,1fh
- stosw ;save hours
- mov ax,bx
- mov cl,5
- shr ax,cl ;shift down minutes
- and ax,3fh
- stosw ;save minutes
- mov ax,bx
- and ax,1fh
- shl ax,1 ;*2
- stosw ;save seconds
- xor ax,ax ;save hundredths = 0
- stosw
- ckfsiz: mov di,@ab+08h[bp] ;see if he wants size
- or di,di ;if==NULL, skip output
- jz ckfatr ;and check file attribute
- lea si,xfilsiz
- lodsw
- stosw
- lodsw
- stosw
- ckfatr: mov di,@ab+0ah[bp] ;see if he wants attribute
- or di,di ;if==NULL, skip output
- mov ax,0
- jz srchex ;and exit
- mov al,xattr
- xor ah,ah
- stosw
- endif
- xor ax,ax
- srchex: push ds
- push ax
- lds dx,dword ptr svdtaof ;ds:dx has old value
- mov ah,1ah
- int 21h
- pop ax
- pop ds
- pop es
- cproce
- endps
- end
-