include	clib.inc
include	dos.inc
include	io.inc

PPROC access, fname:DPTR, amode:word
  ifdef __LFN__
	cmp	_ifsmgr,0
  endif
	MPUSH	ds
	MLDS	dx,fname
	mov	ax,4300h
  ifdef __LFN__
	je	access_21
	mov	ax,7143h
	mov	bl,0
    access_21:
  endif
	int     21h
	MPOP	ds
	jc     	access_error
	cmp	amode,2
	jnz	access_success
	test	cx,_A_RDONLY
	jnz	access_rdonly
    access_success:
	xor	ax,ax
    access_end:
	ret
    access_error:
	call	@dosmaper
    access_rdonly:
	mov	ax,-1
	jmp	access_end
PEND access

	END