home *** CD-ROM | disk | FTP | other *** search
- ;unsigned short seek_file(path);
- ; char *path;
-
- EXTRN _memory_model:byte
-
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:_TEXT
- PUBLIC _seek_file
- _seek_file proc near
- push bp ;
- mov bp,sp ;
- push si ;
- cmp _memory_model,0 ;near or far?
- jle begin ;jump if near
- inc bp ;else add 2 to BP
- inc bp ;
- begin: push ds ;save Turbo's DS
- cmp _memory_model,2 ;data near or far?
- jb L0 ;jump if near
- lds si,dword ptr[bp+4] ;get string address
- jmp short L00 ;
- L0: mov si,[bp+4] ;
- L00: mov dx,si ;pt DX to string too
- cmp byte ptr[si],0 ;test for null string
- je L1 ;
- mov ah,3dh ;function to open file
- mov al,0 ;subfunction to read file
- int 21h ;open the file
- jc L2 ;jump if error, return code in AX
- mov bx,ax ;shift handle to BX
- mov ah,3eh ;func to close file
- int 21h ;close the file
- sub ax,ax ;return 0 if file found
- jmp short L2 ;
- L1: mov ax,2 ;null string return code
- L2: pop ds ;
- pop si ;
- pop bp ;
- cld ;
- cmp _memory_model,0 ;quit
- jle quit ;
- db 0CBh ;RET far
- quit: ret ;RET near
- _seek_file endp
- _TEXT ENDS
- END