summaryrefslogtreecommitdiff
path: root/src/port
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-09-10 20:12:01 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-09-10 20:12:01 +0000
commit336ebee2c049a77d438876ef7cbeda2beff8e8c2 (patch)
treec19cfcbe05c0f1521d8e8fad20079ead7fc50803 /src/port
parentd16b8776123ffe9e287dc2354e3ad5248231055f (diff)
downloadpostgresql-336ebee2c049a77d438876ef7cbeda2beff8e8c2.tar.gz
copydir() is supposed to return on failure, not elog(ERROR). Reduce
ERROR to WARNING so we keep control.
Diffstat (limited to 'src/port')
-rw-r--r--src/port/copydir.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/port/copydir.c b/src/port/copydir.c
index 68959971fd..29fbad8e25 100644
--- a/src/port/copydir.c
+++ b/src/port/copydir.c
@@ -1,7 +1,9 @@
/*
* While "xcopy /e /i /q" works fine for copying directories, on Windows XP
- * it requires an Window handle which prevents it from working when invoked
+ * it requires a Window handle which prevents it from working when invoked
* as a service.
+ *
+ * $Header: /cvsroot/pgsql/src/port/Attic/copydir.c,v 1.5 2003/09/10 20:12:01 tgl Exp $
*/
#include "postgres.h"
@@ -12,6 +14,14 @@
#include <dirent.h>
+/*
+ * copydir: copy a directory (we only need to go one level deep)
+ *
+ * Return 0 on success, nonzero on failure.
+ *
+ * NB: do not elog(ERROR) on failure. Return to caller so it can try to
+ * clean up.
+ */
int
copydir(char *fromdir, char *todir)
{
@@ -22,18 +32,18 @@ copydir(char *fromdir, char *todir)
if (mkdir(todir) != 0)
{
- ereport(ERROR,
+ ereport(WARNING,
(errcode_for_file_access(),
errmsg("could not create directory \"%s\": %m", todir)));
- return 1;
+ return -1;
}
xldir = opendir(fromdir);
if (xldir == NULL)
{
- ereport(ERROR,
+ ereport(WARNING,
(errcode_for_file_access(),
errmsg("could not open directory \"%s\": %m", fromdir)));
- return 1;
+ return -1;
}
while ((xlde = readdir(xldir)) != NULL)
@@ -42,14 +52,11 @@ 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);
- errno = save_errno;
- ereport(ERROR,
+ ereport(WARNING,
(errcode_for_file_access(),
errmsg("could not copy file \"%s\": %m", fromfl)));
- return 1;
+ closedir(xldir);
+ return -1;
}
}