1010 *Win32 (NT, Win2k, XP).replace() doesn't work on Win95/98/Me.
1111 *
1212 * IDENTIFICATION
13- * $PostgreSQL: pgsql/src/port/dirmod.c,v 1.36 2005/02/22 04:43:16 momjian Exp $
13+ * $PostgreSQL: pgsql/src/port/dirmod.c,v 1.37 2005/03/24 02:11:20 tgl Exp $
1414 *
1515 *-------------------------------------------------------------------------
1616 */
@@ -326,10 +326,19 @@ fnames(char *path)
326326
327327dir = opendir (path );
328328if (dir == NULL )
329+ {
330+ #ifndef FRONTEND
331+ elog (WARNING ,"could not open directory \"%s\": %m" ,path );
332+ #else
333+ fprintf (stderr ,_ ("could not open directory \"%s\": %s\n" ),
334+ path ,strerror (errno ));
335+ #endif
329336return NULL ;
337+ }
330338
331339filenames = (char * * )palloc (fnsize * sizeof (char * ));
332340
341+ errno = 0 ;
333342while ((file = readdir (dir ))!= NULL )
334343{
335344if (strcmp (file -> d_name ,"." )!= 0 && strcmp (file -> d_name ,".." )!= 0 )
@@ -342,6 +351,25 @@ fnames(char *path)
342351}
343352filenames [numnames ++ ]= pstrdup (file -> d_name );
344353}
354+ errno = 0 ;
355+ }
356+ #ifdef WIN32
357+
358+ /*
359+ * This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but
360+ * not in released version
361+ */
362+ if (GetLastError ()== ERROR_NO_MORE_FILES )
363+ errno = 0 ;
364+ #endif
365+ if (errno )
366+ {
367+ #ifndef FRONTEND
368+ elog (WARNING ,"could not read directory \"%s\": %m" ,path );
369+ #else
370+ fprintf (stderr ,_ ("could not read directory \"%s\": %s\n" ),
371+ path ,strerror (errno ));
372+ #endif
345373}
346374
347375filenames [numnames ]= NULL ;
@@ -434,7 +462,8 @@ rmtree(char *path, bool rmtopdir)
434462#ifndef FRONTEND
435463elog (WARNING ,"could not remove file or directory \"%s\": %m" ,filepath );
436464#else
437- fprintf (stderr ,_ ("could not remove file or directory \"%s\": %s\n" ),filepath ,strerror (errno ));
465+ fprintf (stderr ,_ ("could not remove file or directory \"%s\": %s\n" ),
466+ filepath ,strerror (errno ));
438467#endif
439468fnames_cleanup (filenames );
440469return false;