--- ../../../../cygio.h 2003-11-17 13:51:10.378169600 -0600 +++ cygio.h 2003-11-17 15:59:37.931086400 -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,34 @@ 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 find_data. + * Then convert the UNICODE strings to multibyte strings. + */ + memcpy (find_data, &wfind_data, offsetof (WIN32_FIND_DATA, + cFileName)); + sys_wcstombs (find_data->cFileName, wfind_data->cFileName, + sizeof(find_data->cFileName)); + sys_wcstombs (find_data->cAlternateFileName, + wfind_data->cAlternateFileName, + sizeof(find_data->cAlternateFileName)); + } + } + } + return handle; } @@ -212,7 +239,7 @@ return GetFileAttributesA (filename); case IOThunkState::WIDE: return GetFileAttributesW (state.getWide()); - }; + } } inline BOOL @@ -227,7 +254,7 @@ return SetFileAttributesA(filename, attr); case IOThunkState::WIDE: return SetFileAttributesW(state.getWide(), attr); - }; + } } inline BOOL