Workaround bogus assertion failure in MSVC 8 (Express, 2005) RTL by switching

from the old _findfirst, _findnext file enumeration API to the newer
FindFirstFile, FindNextFile API.  Might be slower, but won't crash if it finds
files older than 1970.  Bug 331404. r=julien.pierre
This commit is contained in:
nelson%bolyard.com 2006-07-19 01:33:41 +00:00
Родитель a56d754411
Коммит fa48f0c9c9
1 изменённых файлов: 14 добавлений и 15 удалений

Просмотреть файл

@ -245,8 +245,8 @@ EnumSystemFiles(PRInt32 (*func)(const char *))
char szSysDir[_MAX_PATH];
char szFileName[_MAX_PATH];
#ifdef _WIN32
struct _finddata_t fdData;
long lFindHandle;
WIN32_FIND_DATA fdData;
HANDLE lFindHandle;
#else
struct _find_t fdData;
#endif
@ -260,28 +260,27 @@ EnumSystemFiles(PRInt32 (*func)(const char *))
strcat(szFileName, "\\*.*");
#ifdef _WIN32
lFindHandle = _findfirst(szFileName, &fdData);
if (lFindHandle == -1)
lFindHandle = FindFirstFile(szFileName, &fdData);
if (lFindHandle == INVALID_HANDLE_VALUE)
return FALSE;
do {
// pass the full pathname to the callback
sprintf(szFileName, "%s\\%s", szSysDir, fdData.cFileName);
(*func)(szFileName);
iStatus = FindNextFile(lFindHandle, &fdData);
} while (iStatus != 0);
FindClose(lFindHandle);
#else
if (_dos_findfirst(szFileName, _A_NORMAL | _A_RDONLY | _A_ARCH | _A_SUBDIR, &fdData) != 0)
if (_dos_findfirst(szFileName,
_A_NORMAL | _A_RDONLY | _A_ARCH | _A_SUBDIR, &fdData) != 0)
return FALSE;
#endif
do {
// pass the full pathname to the callback
sprintf(szFileName, "%s\\%s", szSysDir, fdData.name);
(*func)(szFileName);
#ifdef _WIN32
iStatus = _findnext(lFindHandle, &fdData);
#else
iStatus = _dos_findnext(&fdData);
#endif
} while (iStatus == 0);
#ifdef _WIN32
_findclose(lFindHandle);
_dos_findclose(&fdData);
#endif
return TRUE;