--- ../../../../cygio.h 2003-11-17 13:51:10.378169600 -0600 +++ ./cygio.h 2003-11-18 09:12:27.139097600 -0600 @@ -1,7 +1,7 @@ /* cygio.h Copyright 2003 Robert Collins - Copyright 2003 Ron Parker + Copyright 2003 Ron Parker This file is part of Cygwin. @@ -145,7 +145,7 @@ trace_file_wcs(state); return CreateFileW (state.getWide(), access, share_mode, sec_attr, disposition, flags, template_file); - }; + } } inline BOOL @@ -160,7 +160,7 @@ return CreateDirectoryA (filename, sec_attr); case IOThunkState::WIDE: return CreateDirectoryW (state.getWide(), sec_attr); - }; + } } inline BOOL @@ -189,7 +189,32 @@ find_first_file (LPCSTR filename, LPWIN32_FIND_DATA data) { /* INVALID_HANDLE_VALUE is failure */ - return FindFirstFile (filename, data); + HANDLE handle = INVALID_HANDLE_VALUE; + IOThunkState state(filename); + switch (state.condition) + { + case IOThunkState::ANSI: + handle = FindFirstFileA (filename, data); + break; + case IOThunkState::WIDE: + { + WIN32_FIND_DATAW wdata; + trace_file_wcs(state); + handle = FindFirstFileW (state.getWide(), &wdata); + if (handle != INVALID_HANDLE_VALUE) + { + /* Copy the start of the UNICODE find data into data. Then convert + * the UNICODE strings to multibyte strings. + */ + memcpy (data, &wdata, offsetof (WIN32_FIND_DATA, cFileName)); + sys_wcstombs (data->cFileName, wdata.cFileName, + sizeof(data->cFileName)); + sys_wcstombs (data->cAlternateFileName, wdata.cAlternateFileName, + sizeof(data->cAlternateFileName)); + } + } + } + return handle; } @@ -212,7 +237,7 @@ return GetFileAttributesA (filename); case IOThunkState::WIDE: return GetFileAttributesW (state.getWide()); - }; + } } inline BOOL @@ -227,7 +252,7 @@ return SetFileAttributesA(filename, attr); case IOThunkState::WIDE: return SetFileAttributesW(state.getWide(), attr); - }; + } } inline BOOL