aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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 7a91450695b..be26db4dc2f 100644
--- a/src/port/dirent.c
+++ b/src/port/dirent.c
@@ -83,7 +83,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;
}
}
@@ -91,13 +95,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;
}
}