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

HANDLE WINAPI
FindFirstFile(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData)
{
	char *path;
	WIN32_FIND_DATAA data;
	HANDLE h;

	if(win_useunicode)
		return FindFirstFileW(lpFileName, lpFindFileData);

	path = win_wstr2utf(lpFileName);
	h = FindFirstFileA(path, &data);
	if(h == INVALID_HANDLE_VALUE)
		return h;
	win_free(path);
	win_convfiledata(lpFindFileData, &data);
	return h;
}
