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

DWORD WINAPI
GetCurrentDirectory(DWORD nBufferLength, LPWSTR lpBuffer)
{
	char *path;
	int n;

	if(win_useunicode)
		return GetCurrentDirectoryW(nBufferLength, lpBuffer);

	path = win_malloc(UTFmax*nBufferLength);
	n = GetCurrentDirectoryA(UTFmax*nBufferLength, path);
	if(n == 0){
		win_free(path);
		return 0;
	}
	n = win_utf2wstrn(lpBuffer, nBufferLength, path);
	win_free(path);
	return n;
}


syntax highlighted by Code2HTML, v. 0.9.1