diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-03-24 02:11:20 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-03-24 02:11:20 +0000 |
| commit | 0ca91482fa1b2f1c01f926503b3de29291d315fc (patch) | |
| tree | 986d744c5283a8220f9ebaa67f243143dfbd91b8 /src/port/copydir.c | |
| parent | c58071a5d1b296cc0fcf9829de2b873cb91e9cc2 (diff) | |
Add missing error checking in readdir() loops.
Diffstat (limited to 'src/port/copydir.c')
| -rw-r--r-- | src/port/copydir.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/port/copydir.c b/src/port/copydir.c index e77fcb6aeb7..6062da96a84 100644 --- a/src/port/copydir.c +++ b/src/port/copydir.c @@ -11,7 +11,7 @@ * as a service. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/copydir.c,v 1.10 2004/12/31 22:03:53 pgsql Exp $ + * $PostgreSQL: pgsql/src/port/copydir.c,v 1.11 2005/03/24 02:11:20 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -56,6 +56,7 @@ copydir(char *fromdir, char *todir) return -1; } + errno = 0; while ((xlde = readdir(xldir)) != NULL) { snprintf(fromfl, MAXPGPATH, "%s/%s", fromdir, xlde->d_name); @@ -68,6 +69,24 @@ copydir(char *fromdir, char *todir) FreeDir(xldir); return -1; } + errno = 0; + } +#ifdef WIN32 + + /* + * This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but + * not in released version + */ + if (GetLastError() == ERROR_NO_MORE_FILES) + errno = 0; +#endif + if (errno) + { + ereport(WARNING, + (errcode_for_file_access(), + errmsg("could not read directory \"%s\": %m", fromdir))); + FreeDir(xldir); + return -1; } FreeDir(xldir); |
