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

HANDLE WINAPI
CreateFile(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
    LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition,
    DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{
	char *path;
	HANDLE h;

	if(win_useunicode)
		return CreateFileW(lpFileName, dwDesiredAccess, dwShareMode,
			lpSecurityAttributes, dwCreationDisposition,
			dwFlagsAndAttributes, hTemplateFile);

	path = win_wstr2utf(lpFileName);
	h = CreateFileA(path, dwDesiredAccess, dwShareMode,
			lpSecurityAttributes, dwCreationDisposition,
			dwFlagsAndAttributes, hTemplateFile);	
	win_free(path);
	return h;
}
