#include <9pm/windows.h>
#include <9pm/u.h>
#include <9pm/libc.h>

DWORD WINAPI
GetFullPathName(LPCWSTR lpFileName, DWORD nBufferLength, LPWSTR lpBuffer,
	LPWSTR *lpFilePart)
{
	char *path, *buf, *last;
	int n;

	if(win_useunicode)
		return GetFullPathNameW(lpFileName, nBufferLength, lpBuffer,
			lpFilePart);

	path = win_wstr2utf(lpFileName);
	buf = win_malloc(nBufferLength*UTFmax);
	n = GetFullPathNameA(path, nBufferLength*UTFmax, buf, &last);
	if(n == 0){
		win_free(buf);
		return 0;
	}
	n = win_utf2wstrn(lpBuffer, nBufferLength, buf);
	win_free(buf);
	/* this is not right but it will do */
	*lpFilePart = lpBuffer;
	return n;
}
