]> git.sur5r.net Git - bacula/bacula/commitdiff
bugfix for c:/ or c:\\ (didn't work correctly on win32 if root dir was given)
authorThorsten Engel <thorsten.engel@matrix-computer.com>
Mon, 27 Mar 2006 09:33:13 +0000 (09:33 +0000)
committerThorsten Engel <thorsten.engel@matrix-computer.com>
Mon, 27 Mar 2006 09:33:13 +0000 (09:33 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2864 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/win32/compat/compat.cpp

index 70e6e53efa1888428776a62727fcdb1dc863958e..0b864b198dd20353cf8c4ce8e9e925942010fd3d 100644 (file)
@@ -70,7 +70,8 @@ void conv_unix_to_win32_path(const char *name, char *win32_name, DWORD dwSize)
         name++;
     }
     /* Strip any trailing slash, if we stored something */
-    if (*fname != 0 && win32_name[-1] == '\\') {
+    /* but leave "c:\" with backslash (root directory case */
+    if (*fname != 0 && win32_name[-1] == '\\' && strlen (fname) != 3) {
         win32_name[-1] = 0;
     } else {
         *win32_name = 0;
@@ -134,7 +135,7 @@ make_wchar_win32_path(POOLMEM* pszUCSPath, BOOL* pBIsRawPath /*= NULL*/)
    BOOL bAddPrefix = TRUE;
 
    /* does path begin with drive? if yes, it is absolute */
-   if (wcslen(name) > 3 && (iswalpha (*name) && *(name+1) == ':'
+   if (wcslen(name) >= 3 && (iswalpha (*name) && *(name+1) == ':'
        && (*(name+2) == '\\' || *(name+2) == '/'))) {
       bAddDrive = FALSE;
       bAddCurrentPath = FALSE;
@@ -873,7 +874,12 @@ opendir(const char *path)
        conv_unix_to_win32_path(path, tspec, max_len);
     }
 
-    bstrncat(tspec, "\\*", max_len);
+    // add backslash only if there is none yet (think of c:\)
+    if (tspec[strlen(tspec)-1] != '\\')
+      bstrncat(tspec, "\\*", max_len);
+    else
+      bstrncat(tspec, "*", max_len);
+
     rval->spec = tspec;
 
     // convert to WCHAR