include	clib.inc
include	dos.inc
include	console.inc

PPROC	getcwdd, path:DPTR, disk:word
	push	si
	MPUSH	ds
  ifdef __LFN__
	mov	cx,console
	mov	al,_ifsmgr
	test	al,al
  endif
	MLDS	si,path
	mov	dx,disk	; drive number (DL, 0 = default)
	mov	ah,47h
  ifdef __LFN__
	jz	wgetcwd_21h
	test	cl,CON_NTCMD
	jz	wgetcwd_21h
	stc
	xchg	al,ah
    wgetcwd_21h:
  endif
	int	21h
	MPOP	ds
	jc	getcwdd_err
	mov	ax,word ptr path
	MMOV	dx,word ptr path+2
    getcwdd_end:
	pop	si
	ret
    getcwdd_err:
	call	@dosmaper
	xor	ax,ax
	cwd
	jmp	getcwdd_end
PEND	getcwdd

	END
