Quellcode durchsuchen

Fix error handling in readdir in minirent.h

rexim vor 4 Jahren
Ursprung
Commit
9c963a7729
1 geänderte Dateien mit 6 neuen und 3 gelöschten Zeilen
  1. 6 3
      minirent.h

+ 6 - 3
minirent.h

@@ -82,9 +82,12 @@ struct dirent *readdir(DIR *dirp)
         dirp->dirent = (struct dirent*)calloc(1, sizeof(struct dirent));
     } else {
         if(!FindNextFile(dirp->hFind, &dirp->data)) {
-            // TODO: readdir should set errno accordingly on FindFirstFile fail
-            // https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-getlasterror
-            errno = ENOSYS;
+            if (GetLastError() != ERROR_NO_MORE_FILES) {
+                // TODO: readdir should set errno accordingly on FindFirstFile fail
+                // https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-getlasterror
+                errno = ENOSYS;
+            }
+
             return NULL;
         }
     }