diff options
Diffstat (limited to 'src/port/pgcheckdir.c')
-rw-r--r-- | src/port/pgcheckdir.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/port/pgcheckdir.c b/src/port/pgcheckdir.c index fc97f8cc1da..502d4f377d9 100644 --- a/src/port/pgcheckdir.c +++ b/src/port/pgcheckdir.c @@ -33,14 +33,11 @@ pg_check_dir(const char *dir) struct dirent *file; bool dot_found = false; - 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) @@ -68,17 +65,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? */ /* We report on dot-files if we _only_ find dot files */ |