]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/findlib/create_file.c
This commit was manufactured by cvs2svn to create tag
[bacula/bacula] / bacula / src / findlib / create_file.c
index 9144bfc10a4a0614693cb7dd90e2bb96df431466..df23f85635d7c15689b82f7ababe1511be010046 100644 (file)
@@ -111,7 +111,13 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace)
    case FT_SPEC:
    case FT_REGE:                      /* empty file */
    case FT_REG:                       /* regular file */
-      if (exists) {
+      /* 
+       * Note, we do not delete FT_RAW because these are device files
+       *  or FIFOs that should already exist. If we blow it away,
+       *  we may blow away a FIFO that is being used to read the
+       *  restore data, or we may blow away a partition definition.
+       */
+      if (exists && attr->type != FT_RAW && attr->type != FT_FIFO) {
          /* Get rid of old copy */
          if (unlink(attr->ofname) == -1) {
             berrno be;
@@ -167,7 +173,7 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace)
          }
          Dmsg1(50, "Create file: %s\n", attr->ofname);
          if (is_bopen(bfd)) {
-            Jmsg1(jcr, M_ERROR, 0, "bpkt already open fid=%d\n", bfd->fid);
+            Jmsg1(jcr, M_ERROR, 0, _("bpkt already open fid=%d\n"), bfd->fid);
             bclose(bfd);
          }
          /*
@@ -268,7 +274,7 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace)
                tid = NULL;
             }
             if (is_bopen(bfd)) {
-               Jmsg1(jcr, M_ERROR, 0, "bpkt already open fid=%d\n", bfd->fid);
+               Jmsg1(jcr, M_ERROR, 0, _("bpkt already open fid=%d\n"), bfd->fid);
             }
             if ((bopen(bfd, attr->ofname, mode, 0)) < 0) {
                berrno be;
@@ -319,7 +325,7 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace)
        */
       if (!is_portable_backup(bfd)) {
          if (is_bopen(bfd)) {
-            Jmsg1(jcr, M_ERROR, 0, "bpkt already open fid=%d\n", bfd->fid);
+            Jmsg1(jcr, M_ERROR, 0, _("bpkt already open fid=%d\n"), bfd->fid);
          }
          if ((bopen(bfd, attr->ofname, O_WRONLY|O_BINARY, 0)) < 0) {
             berrno be;
@@ -365,20 +371,30 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace)
  */
 static int separate_path_and_file(JCR *jcr, char *fname, char *ofile)
 {
-   char *f, *p;
+   char *f, *p, *q;
    int fnl, pnl;
 
    /* Separate pathname and filename */
-   for (p=f=ofile; *p; p++) {
+   for (q=p=f=ofile; *p; p++) {
       if (*p == '/') {
-         f = p;                    /* possible filename */
+         f = q;                    /* possible filename */
+      }
+#ifdef HAVE_WIN32
+      if (*p == '\\') {            /* strip backslashes on Win32 */
+         continue;
       }
+      *q++ = *p;                   /* copy data */
+#else
+      q++;
+#endif
    }
+
    if (*f == '/') {
       f++;
    }
+   *q = 0;                         /* terminate string */
 
-   fnl = p - f;
+   fnl = q - f;
    if (fnl == 0) {
       /* The filename length must not be zero here because we
        *  are dealing with a file (i.e. FT_REGE or FT_REG).
@@ -402,7 +418,7 @@ static int path_already_seen(JCR *jcr, char *path, int pnl)
    if (jcr->cached_pnl == pnl && strcmp(path, jcr->cached_path) == 0) {
       return 1;
    }
-   pm_strcpy(&jcr->cached_path, path);
+   pm_strcpy(jcr->cached_path, path);
    jcr->cached_pnl = pnl;
    return 0;
 }