Skip to content

Commit 9216c89

Browse files
committed
rmtree() reported the wrong pathname if final rmdir failed.
1 parent 35c4764 commit 9216c89

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/port/dirmod.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
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.37 2005/03/24 02:11:20 tgl Exp $
13+
* $PostgreSQL: pgsql/src/port/dirmod.c,v 1.38 2005/08/02 15:14:47 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -281,10 +281,10 @@ pgsymlink(const char *oldpath, const char *newpath)
281281
#ifndef FRONTEND
282282
ereport(ERROR,
283283
(errcode_for_file_access(),
284-
errmsg("Error setting junction for %s: %s",
284+
errmsg("could not set junction for \"%s\": %s",
285285
nativeTarget, msg)));
286286
#else
287-
fprintf(stderr, _("Error setting junction for %s: %s\n"),
287+
fprintf(stderr, _("could not set junction for \"%s\": %s\n"),
288288
nativeTarget, msg);
289289
#endif
290290
LocalFree(msg);
@@ -408,7 +408,8 @@ fnames_cleanup(char **filenames)
408408
bool
409409
rmtree(char *path, bool rmtopdir)
410410
{
411-
char filepath[MAXPGPATH];
411+
char pathbuf[MAXPGPATH];
412+
char *filepath;
412413
char **filenames;
413414
char **filename;
414415
struct stat statbuf;
@@ -423,6 +424,7 @@ rmtree(char *path, bool rmtopdir)
423424
return false;
424425

425426
/* now we have the names we can start removing things */
427+
filepath = pathbuf;
426428

427429
for (filename = filenames; *filename; filename++)
428430
{
@@ -450,7 +452,8 @@ rmtree(char *path, bool rmtopdir)
450452

451453
if (rmtopdir)
452454
{
453-
if (rmdir(path) != 0)
455+
filepath = path;
456+
if (rmdir(filepath) != 0)
454457
goto report_and_fail;
455458
}
456459

0 commit comments

Comments
 (0)