diff options
| author | Tom Lane | 2003-07-27 17:10:07 +0000 |
|---|---|---|
| committer | Tom Lane | 2003-07-27 17:10:07 +0000 |
| commit | e8db9b26d03b9e58a30eb26ec2ee21c92293d3a2 (patch) | |
| tree | c2adf83074db369ea5211b06e5181ebabf1a61d8 /src/port | |
| parent | aeea73d4eceb9b33ff16a69c77bd923a0394a6d0 (diff) | |
elog mop-up.
Diffstat (limited to 'src/port')
| -rw-r--r-- | src/port/copydir.c | 18 | ||||
| -rw-r--r-- | src/port/dirmod.c | 28 |
2 files changed, 30 insertions, 16 deletions
diff --git a/src/port/copydir.c b/src/port/copydir.c index 81a36cca4a3..53a819d38df 100644 --- a/src/port/copydir.c +++ b/src/port/copydir.c @@ -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; } } diff --git a/src/port/dirmod.c b/src/port/dirmod.c index 21c205a5d0f..6d680a41501 100644 --- a/src/port/dirmod.c +++ b/src/port/dirmod.c @@ -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 |
