aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/port/dirent.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/port/dirent.c b/src/port/dirent.c
index f59e8ef9475..8835a6b1f54 100644
--- a/src/port/dirent.c
+++ b/src/port/dirent.c
@@ -84,7 +84,11 @@ readdir(DIR *d)
d->handle = FindFirstFile(d->dirname, &fd);
if (d->handle == INVALID_HANDLE_VALUE)
{
- errno = ENOENT;
+ /* If there are no files, force errno=0 (unlike mingw) */
+ if (GetLastError() == ERROR_FILE_NOT_FOUND)
+ errno = 0;
+ else
+ _dosmaperr(GetLastError());
return NULL;
}
}
@@ -92,13 +96,11 @@ readdir(DIR *d)
{
if (!FindNextFile(d->handle, &fd))
{
+ /* If there are no more files, force errno=0 (like mingw) */
if (GetLastError() == ERROR_NO_MORE_FILES)
- {
- /* No more files, force errno=0 (unlike mingw) */
errno = 0;
- return NULL;
- }
- _dosmaperr(GetLastError());
+ else
+ _dosmaperr(GetLastError());
return NULL;
}
}