aboutsummaryrefslogtreecommitdiff
path: root/src/port/pgcheckdir.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/port/pgcheckdir.c')
-rw-r--r--src/port/pgcheckdir.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/port/pgcheckdir.c b/src/port/pgcheckdir.c
index 9453bcb68a6..3a2a34cbc61 100644
--- a/src/port/pgcheckdir.c
+++ b/src/port/pgcheckdir.c
@@ -32,14 +32,12 @@ pg_check_dir(const char *dir)
DIR *chkdir;
struct dirent *file;
- errno = 0;
-
chkdir = opendir(dir);
if (chkdir == NULL)
return (errno == ENOENT) ? 0 : -1;
- while ((file = readdir(chkdir)) != NULL)
+ while (errno = 0, (file = readdir(chkdir)) != NULL)
{
if (strcmp(".", file->d_name) == 0 ||
strcmp("..", file->d_name) == 0)
@@ -55,18 +53,12 @@ pg_check_dir(const char *dir)
}
#ifdef WIN32
-
- /*
- * This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but not in
- * released version
- */
+ /* Bug in old Mingw dirent.c; fixed in mingw-runtime-3.2, 2003-10-10 */
if (GetLastError() == ERROR_NO_MORE_FILES)
errno = 0;
#endif
- closedir(chkdir);
-
- if (errno != 0)
+ if (errno || closedir(chkdir))
result = -1; /* some kind of I/O error? */
return result;