* mingwex/dirent.c (_tGetFileAttributes): New helper function.

(_topendir): Use it.
This commit is contained in:
Danny Smith 2006-06-18 08:43:34 +00:00
parent 5ade5bb0ea
commit 71bbb04de9
2 changed files with 25 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2006-06-18 Danny Smith <dannysmith@users.sourceforge.net>
* mingwex/dirent.c (_tGetFileAttributes): New helper function.
(_topendir): Use it.
2006-06-18 Danny Smith <dannysmith@users.sourceforge.net>
* include/sys/time.h: Add header guard. Add extern "C" bracketing

View File

@ -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 */