mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
elog mop-up.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
|
||||
#undef mkdir /* no reason to use that macro because we ignore the 2nd arg */
|
||||
|
||||
#include "dirent.h"
|
||||
#include <dirent.h>
|
||||
|
||||
|
||||
int
|
||||
@@ -21,14 +21,17 @@ copydir(char *fromdir,char *todir)
|
||||
|
||||
if (mkdir(todir) != 0)
|
||||
{
|
||||
elog(ERROR, "could not make directory '%s'",todir);
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not create directory \"%s\": %m", todir)));
|
||||
return 1;
|
||||
}
|
||||
xldir = opendir(fromdir);
|
||||
if (xldir == NULL)
|
||||
{
|
||||
closedir(xldir);
|
||||
elog(ERROR, "could not open directory '%s'",fromdir);
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not open directory \"%s\": %m", fromdir)));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -38,8 +41,13 @@ copydir(char *fromdir,char *todir)
|
||||
snprintf(tofl, MAXPGPATH, "%s/%s", todir, xlde->d_name);
|
||||
if (CopyFile(fromfl,tofl,TRUE) < 0)
|
||||
{
|
||||
int save_errno = errno;
|
||||
|
||||
closedir(xldir);
|
||||
elog(ERROR,"could not create file %s\n",todir);
|
||||
errno = save_errno;
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not copy file \"%s\": %m", fromfl)));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
* These are replacement versions of unlink and rename that work on
|
||||
* Win32 (NT, Win2k, XP). replace() doesn't work on Win95/98/Me.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TEST_VERSION
|
||||
@@ -11,7 +10,8 @@
|
||||
#undef rename
|
||||
#undef unlink
|
||||
|
||||
int pgrename(const char *from, const char *to)
|
||||
int
|
||||
pgrename(const char *from, const char *to)
|
||||
{
|
||||
int loops = 0;
|
||||
|
||||
@@ -23,24 +23,27 @@ int pgrename(const char *from, const char *to)
|
||||
Sleep(100); /* ms */
|
||||
if (loops == 10)
|
||||
#ifndef FRONTEND
|
||||
elog(LOG, "Unable to rename %s to %s, continuing to try", from, to);
|
||||
elog(LOG, "could not rename \"%s\" to \"%s\", continuing to try",
|
||||
from, to);
|
||||
#else
|
||||
fprintf(stderr, "Unable to rename %s to %s, continuing to try\n", from, to);
|
||||
fprintf(stderr, "could not rename \"%s\" to \"%s\", continuing to try\n",
|
||||
from, to);
|
||||
#endif
|
||||
loops++;
|
||||
}
|
||||
|
||||
if (loops > 10)
|
||||
#ifndef FRONTEND
|
||||
elog(LOG, "Completed rename of %s to %s", from, to);
|
||||
elog(LOG, "completed rename of \"%s\" to \"%s\"", from, to);
|
||||
#else
|
||||
fprintf(stderr, "Completed rename of %s to %s\n", from, to);
|
||||
fprintf(stderr, "completed rename of \"%s\" to \"%s\"\n", from, to);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int pgunlink(const char *path)
|
||||
int
|
||||
pgunlink(const char *path)
|
||||
{
|
||||
int loops = 0;
|
||||
|
||||
@@ -52,18 +55,20 @@ int pgunlink(const char *path)
|
||||
Sleep(100); /* ms */
|
||||
if (loops == 10)
|
||||
#ifndef FRONTEND
|
||||
elog(LOG, "Unable to unlink %s, continuing to try", path);
|
||||
elog(LOG, "could not unlink \"%s\", continuing to try",
|
||||
path);
|
||||
#else
|
||||
fprintf(stderr, "Unable to unlink %s, continuing to try\n", path);
|
||||
fprintf(stderr, "could not unlink \"%s\", continuing to try\n",
|
||||
path);
|
||||
#endif
|
||||
loops++;
|
||||
}
|
||||
|
||||
if (loops > 10)
|
||||
#ifndef FRONTEND
|
||||
elog(LOG, "Completed unlink of %s", path);
|
||||
elog(LOG, "completed unlink of \"%s\"", path);
|
||||
#else
|
||||
fprintf(stderr, "Completed unlink of %s\n", path);
|
||||
fprintf(stderr, "completed unlink of \"%s\"\n", path);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@@ -143,4 +148,5 @@ main(int argc, char* argv[])
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user