home *** CD-ROM | disk | FTP | other *** search
- include compiler.inc
-
- ttl FINFO, 1.01, 8-22-86, clr
-
- ; multiple entry point --
- ; fstat(filename,&s_stat) -- return structure as defined in stat.h
- ; fsize(filename) - file size in bytes
- ; fdate(filename) - file date in 2 bytes (encoded)
- ; ftime(filename) - file time in 2 bytes (encoded)
- ; jim -- we probably should also write a function
- ; to convert from packed format to normal format
- ;
- ; findfirst(pathname,filename,attribute) - find first matching file
- ; findnext(filename) - find next matching file
- ;
- ; these functions use DOS Functions 4E and 4F
- ;
- ;
-
- dseg
- exterr
-
- dtaptr equ this byte
- rsvd db 21 dup(0)
- attrf db 0
- timef dw 0
- datef dw 0
- sizef dd 0
- namef db 13 dup(0)
-
- cseg
- flag db 0
-
- ; flag value is: 0 for file size
- ; 1 for file time
- ; 2 for file date
-
- procdef fstat <<filename,ptr>,<status,ptr>>
- mov flag,3
- jmp finfo
-
- entrdef fsize
- mov flag,0
- jmp finfo
-
- entrdef ftime
- mov flag,1
- jmp finfo
-
- entrdef fdate
- mov flag,2
-
- finfo:
- pushds
- call setdta ;local procedure
- push ds
- ldptr dx,filename,ds
- xor cx,cx
- call dofirst
- pop ds
- or ax,ax
- jnz errexit
- mov al,flag
- caseb 0,siz
- caseb 1,tim
- caseb 2,dat
- stat:
- push es
- push bx
- ldptr bx,status,es
- mov al,byte ptr attrf
- mov es:[bx],al
- mov ax,word ptr timef
- mov es:[bx+1],ax
- mov ax,word ptr datef
- mov es:[bx+3],ax
- mov ax,word ptr sizef
- mov es:[bx+5],ax
- mov ax,word ptr sizef+2
- mov es:[bx+7],ax
- pop bx
- pop es
- xor ax,ax
- jmp exit
-
- dat:
- mov ax,word ptr datef
- xor dx,dx
- jmp exit
- tim:
- mov ax,word ptr timef
- xor dx,dx
- jmp exit
- siz:
- mov ax,word ptr sizef
- mov dx,word ptr sizef+2
- jmp exit
-
- errexit:
- mov ax,-1
- exit:
- pret
- pend fstat
-
- internal setdta
-
- mov dx,offset dtaptr
- mov ax,1a00h
- int 21h
- ret
- iend setdta
-
- internal dofirst
-
- mov ax,4e00h
- int 21h
- moverr ax
- ret
- iend dofirst
-
-
- ; at least 13 bytes must be allocated to fname -- value not checked!
-
- procdef findfirst <<pname,ptr>,<fname,ptr>,<attr,word>>
- pushreg
- pushds
-
- call setdta
- ldptr dx,pname,ds
- mov cx,attr
- call dofirst
- or ax,ax
- jnz errout
- mov si,offset namef
- ldptr di,fname
- mov cx,0dh
- rep movsb
- jmp out1
-
- errout:
- mov ax,-1
- out1:
- pret
- pend findfirst
-
- procdef findnext <<retname,ptr>>
- pushreg
- pushds
-
- mov ax,4f00h
- int 21h
- or ax,ax
- jnz err
-
- mov si,offset namef
- ldptr di,retname
- mov cx,0dh
- rep movsb
- jmp ok
-
- err:
- moverr ax
- mov ax,-1
- ok:
- pret
- pend findnext
-
- finish