1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-21 10:42:50 +03:00

rmtree() reported the wrong pathname if final rmdir failed.

This commit is contained in:
Tom Lane
2005-08-02 15:14:56 +00:00
parent ae1d34f23a
commit 668448d6f0

View File

@@ -10,7 +10,7 @@
* Win32 (NT, Win2k, XP). replace() doesn't work on Win95/98/Me. * Win32 (NT, Win2k, XP). replace() doesn't work on Win95/98/Me.
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/port/dirmod.c,v 1.34.4.2 2005/03/24 02:11:33 tgl Exp $ * $PostgreSQL: pgsql/src/port/dirmod.c,v 1.34.4.3 2005/08/02 15:14:56 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@@ -280,10 +280,10 @@ pgsymlink(const char *oldpath, const char *newpath)
#ifndef FRONTEND #ifndef FRONTEND
ereport(ERROR, ereport(ERROR,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("Error setting junction for %s: %s", errmsg("could not set junction for \"%s\": %s",
nativeTarget, msg))); nativeTarget, msg)));
#else #else
fprintf(stderr, "Error setting junction for %s: %s\n", fprintf(stderr, "could not set junction for \"%s\": %s\n",
nativeTarget, msg); nativeTarget, msg);
#endif #endif
LocalFree(msg); LocalFree(msg);
@@ -407,7 +407,8 @@ fnames_cleanup(char **filenames)
bool bool
rmtree(char *path, bool rmtopdir) rmtree(char *path, bool rmtopdir)
{ {
char filepath[MAXPGPATH]; char pathbuf[MAXPGPATH];
char *filepath;
char **filenames; char **filenames;
char **filename; char **filename;
struct stat statbuf; struct stat statbuf;
@@ -422,6 +423,7 @@ rmtree(char *path, bool rmtopdir)
return false; return false;
/* now we have the names we can start removing things */ /* now we have the names we can start removing things */
filepath = pathbuf;
for (filename = filenames; *filename; filename++) for (filename = filenames; *filename; filename++)
{ {
@@ -449,7 +451,8 @@ rmtree(char *path, bool rmtopdir)
if (rmtopdir) if (rmtopdir)
{ {
if (rmdir(path) != 0) filepath = path;
if (rmdir(filepath) != 0)
goto report_and_fail; goto report_and_fail;
} }