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.34 2004/12/31 22:03:53 pgsql Exp $
13+ * $PostgreSQL: pgsql/src/port/dirmod.c,v 1.35 2005/02/13 16:50:44 momjian Exp $
1414 *
1515 *-------------------------------------------------------------------------
1616 */
@@ -350,6 +350,7 @@ fnames(char *path)
350350return filenames ;
351351}
352352
353+
353354/*
354355 *fnames_cleanup
355356 *
@@ -366,6 +367,7 @@ fnames_cleanup(char **filenames)
366367pfree (filenames );
367368}
368369
370+
369371/*
370372 *rmtree
371373 *
@@ -398,39 +400,41 @@ rmtree(char *path, bool rmtopdir)
398400snprintf (filepath ,MAXPGPATH ,"%s/%s" ,path ,* filename );
399401
400402if (stat (filepath ,& statbuf )!= 0 )
401- {
402- fnames_cleanup (filenames );
403- return false;
404- }
403+ gotoreport_and_fail ;
405404
406405if (S_ISDIR (statbuf .st_mode ))
407406{
408407/* call ourselves recursively for a directory */
409408if (!rmtree (filepath , true))
410409{
410+ /* we already reported the error */
411411fnames_cleanup (filenames );
412412return false;
413413}
414414}
415415else
416416{
417417if (unlink (filepath )!= 0 )
418- {
419- fnames_cleanup (filenames );
420- return false;
421- }
418+ gotoreport_and_fail ;
422419}
423420}
424421
425422if (rmtopdir )
426423{
427424if (rmdir (path )!= 0 )
428- {
429- fnames_cleanup (filenames );
430- return false;
431- }
425+ gotoreport_and_fail ;
432426}
433427
434428fnames_cleanup (filenames );
435429return true;
430+
431+ report_and_fail :
432+
433+ #ifndef FRONTEND
434+ elog (WARNING ,"could not remove file or directory \"%s\": %m" ,filepath );
435+ #else
436+ fprintf (stderr ,"could not remove file or directory \"%s\": %s\n" ,filepath ,strerror (errno ));
437+ #endif
438+ fnames_cleanup (filenames );
439+ return false;
436440}