diff --git a/winsup/mingw/ChangeLog b/winsup/mingw/ChangeLog index a813425ec..86c63b5ba 100644 --- a/winsup/mingw/ChangeLog +++ b/winsup/mingw/ChangeLog @@ -1,3 +1,8 @@ +2006-06-18 Danny Smith + + * mingwex/dirent.c (_tGetFileAttributes): New helper function. + (_topendir): Use it. + 2006-06-18 Danny Smith * include/sys/time.h: Add header guard. Add extern "C" bracketing diff --git a/winsup/mingw/mingwex/dirent.c b/winsup/mingw/mingwex/dirent.c index 3a841d2a9..399a8d1b3 100644 --- a/winsup/mingw/mingwex/dirent.c +++ b/winsup/mingw/mingwex/dirent.c @@ -28,6 +28,25 @@ #define SUFFIX _T("*") #define SLASH _T("\\") + +/* Helper for opendir(). */ +static inline unsigned _tGetFileAttributes (const _TCHAR * tPath) +{ +#ifdef _UNICODE + /* GetFileAttributesW does not work on W9x, so convert to ANSI */ + if (_osver & 0x8000) + { + char aPath [MAX_PATH]; + WideCharToMultiByte (CP_ACP, 0, tPath, -1, aPath, MAX_PATH, NULL, + NULL); + return GetFileAttributesA (aPath); + } + return GetFileAttributesW (tPath); +#else + return GetFileAttributesA (tPath); +#endif +} + /* * opendir * @@ -56,7 +75,7 @@ _topendir (const _TCHAR *szPath) } /* Attempt to determine if the given path really is a directory. */ - rc = GetFileAttributes (szPath); + rc = _tGetFileAttributes (szPath); if (rc == (unsigned int)-1) { /* call GetLastError for more error info */