include	clib.inc
include	dos.inc
include	string.inc

PPROC	wshortname, path:dword
local	wblk:S_WFBLK
  ifdef __LFN__
	invoke	wfindfirst, path, addr wblk, 00FFh
	cmp	ax,-1
	je	notfound
	invoke	wcloseff, ax
	mov	dx,ds
	xor	ax,ax
	cmp	al,wblk.wf_shortname
	jz	notfound
	mov	[shortname+12],al
	lea	ax,wblk.wf_shortname
	invoke	memcpy, addr shortname, ss::ax, 12
    toend:
	ret
    notfound:
	mov	ax,word ptr path
	mov	dx,word ptr path+2
	jmp	toend
  else
	mov	ax,word ptr path
	mov	dx,word ptr path+2
	ret
  endif
PEND	wshortname

ifdef __LFN__
_DATA	SEGMENT
shortname db 14 dup(?)
_DATA	ENDS
endif
	END