]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/findlib/makepath.c
ebl add restore command line options
[bacula/bacula] / bacula / src / findlib / makepath.c
index dbb873b2baaeb0837483fc4cc38e0cc8bfc9a326..4b292e828f51397bb907db993aecf4d0a62ea100 100644 (file)
    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 /* Written by David MacKenzie <djm@gnu.ai.mit.edu> and Jim Meyering.  */
-
 /*
  *   Modified by Kern Sibbald for use in Bacula, December 2000
  *
  *   Version $Id$
  */
+/*
+   Bacula® - The Network Backup Solution
+
+   Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+
+   The main author of Bacula is Kern Sibbald, with contributions from
+   many others, a complete list can be found in the file AUTHORS.
+   This program is Free Software; you can redistribute it and/or
+   modify it under the terms of version two of the GNU General Public
+   License as published by the Free Software Foundation plus additions
+   that are listed in the file LICENSE.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Bacula® is a registered trademark of John Walker.
+   The licensor of Bacula is the Free Software Foundation Europe
+   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+   Switzerland, email:ftf@fsfeurope.org.
+*/
+
 
 #include "bacula.h"
 #include "jcr.h"
@@ -83,7 +110,7 @@ cleanup(struct saved_cwd *cwd)
 
 /* Attempt to create directory DIR (aka DIRPATH) with the specified MODE.
    If CREATED_DIR_P is non-NULL, set *CREATED_DIR_P to non-zero if this
-   function creates DIR and to zero otherwise. Give a diagnostic and
+   function creates DIR and to zero otherwise.  Give a diagnostic and
    return non-zero if DIR cannot be created or cannot be determined to
    exist already.  Use DIRPATH in any diagnostic, not DIR.
    Note that if DIR already exists, this function will return zero
@@ -104,7 +131,7 @@ make_dir(JCR *jcr, const char *dir, const char *dirpath, mode_t mode, int *creat
       struct stat stats;
 
       /* The mkdir and stat calls below may appear to be reversed.
-         They are not. It is important to call mkdir first and then to
+         They are not.  It is important to call mkdir first and then to
          call stat (to distinguish the three cases) only if mkdir fails.
          The alternative to this approach is to `stat' each directory,
          then to call mkdir if it doesn't exist.  But if some other process
@@ -137,9 +164,9 @@ int
 isAbsolute(const char *path)
 {
 #if defined(HAVE_WIN32)
-    return path[1] == ':' || *path == '/' || *path == '\\';     /* drivespec:/blah is absolute */
+    return path[1] == ':' || IsPathSeparator(*path);     /* drivespec:/blah is absolute */
 #else
-    return *path == '/';
+    return IsPathSeparator(*path);
 #endif
 }
 
@@ -241,7 +268,7 @@ make_path(
       }
 #else
       /* If we can record the current working directory, we may be able
-         to do the chdir optimization. */
+         to do the chdir optimization.  */
       cwd.do_chdir = !save_cwd(&cwd);
 
       slash = dirpath;
@@ -255,31 +282,19 @@ make_path(
       }
 
       /* Skip over leading slashes.  */
-#if defined(HAVE_WIN32)
-      while (*slash == '/' || *slash == '\\')
+      while (IsPathSeparator(*slash))
          slash++;
-#else
-      while (*slash == '/')
-         slash++;
-#endif
-      while (1) {
+
+      for ( ; ; ) {
           int newly_created_dir;
           int fail;
 
           /* slash points to the leftmost unprocessed component of dirpath.  */
           basename_dir = slash;
-
-#if defined(HAVE_WIN32)
-          slash = strpbrk(slash, ":/\\");
-          if (slash == NULL) {
-             break;
-          }
-#else
-          slash = strchr (slash, '/');
+          slash = first_path_separator(slash);
           if (slash == NULL) {
              break;
           }
-#endif
 
           /* If we're *not* doing chdir before each mkdir, then we have to refer
              to the target using the full (multi-component) directory name.  */
@@ -338,13 +353,8 @@ make_path(
 
           /* Avoid unnecessary calls to `stat' when given
              pathnames containing multiple adjacent slashes.  */
-#if defined(HAVE_WIN32)
-         while (*slash == '/' || *slash == '\\')
+         while (IsPathSeparator(*slash))
             slash++;
-#else
-         while (*slash == '/')
-            slash++;
-#endif
       } /* end while (1) */
 
       if (!cwd.do_chdir) {