include	clib.inc
include	dos.inc

PPROC	wgetcwd, path:DPTR, drive:word
	push	si
	MPUSH	ds
  ifdef __LFN__
	mov	al,_ifsmgr
	test	al,al
  endif
	mov	dx,drive
	MLDS	si,path
	mov	ah,47h
  ifdef __LFN__
	jz	wgetcwd_21h
	stc
	mov	ax,7147h
    wgetcwd_21h:
  endif
	int	21h
	MPOP	ds
	jc	wgetcwd_fail
	mov	ax,word ptr path
	MMOV	dx,word ptr path+2
    wgetcwd_end:
	pop	si
	ret
    wgetcwd_fail:
	call	@dosmaper
	xor	ax,ax
	cwd
	jmp	wgetcwd_end
PEND	wgetcwd

	END
