aboutsummaryrefslogtreecommitdiff
path: root/src/common/pgfnames.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/pgfnames.c')
-rw-r--r--src/common/pgfnames.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/common/pgfnames.c b/src/common/pgfnames.c
index 9a68163dd76..51a848a1fdb 100644
--- a/src/common/pgfnames.c
+++ b/src/common/pgfnames.c
@@ -50,8 +50,7 @@ pgfnames(const char *path)
filenames = (char **) palloc(fnsize * sizeof(char *));
- errno = 0;
- while ((file = readdir(dir)) != NULL)
+ while (errno = 0, (file = readdir(dir)) != NULL)
{
if (strcmp(file->d_name, ".") != 0 && strcmp(file->d_name, "..") != 0)
{
@@ -63,14 +62,10 @@ pgfnames(const char *path)
}
filenames[numnames++] = pstrdup(file->d_name);
}
- errno = 0;
}
#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
@@ -87,7 +82,15 @@ pgfnames(const char *path)
filenames[numnames] = NULL;
- closedir(dir);
+ if (closedir(dir))
+ {
+#ifndef FRONTEND
+ elog(WARNING, "could not close directory \"%s\": %m", path);
+#else
+ fprintf(stderr, _("could not close directory \"%s\": %s\n"),
+ path, strerror(errno));
+#endif
+ }
return filenames;
}