]> wimlib.net Git - wimlib/blobdiff - src/win32_capture.c
Improve tstr <=> UTF-16LE conversions
[wimlib] / src / win32_capture.c
index 745ee77a739bbb1712d3baa78ea3023513f0b02b..feac7644466cb027745bc145e9174da22602137d 100644 (file)
@@ -1141,9 +1141,9 @@ win32_build_dentry_tree_recursive(struct wim_dentry **root_ret,
        DWORD desiredAccess;
 
 
-       if (exclude_path(path + params->capture_root_nchars,
-                        path_num_chars - params->capture_root_nchars,
-                        params->config))
+       if (should_exclude_path(path + params->capture_root_nchars,
+                               path_num_chars - params->capture_root_nchars,
+                               params->config))
        {
                ret = 0;
                goto out_progress;
@@ -1411,6 +1411,16 @@ win32_build_dentry_tree(struct wim_dentry **root_ret,
                wmemcpy(path, root_disk_path, path_nchars + 1);
        }
 
+       /* Strip trailing slashes.  If we don't do this, we may create a path
+       * with multiple consecutive backslashes, which for some reason causes
+       * Windows to report that the file cannot be found.  */
+       while (path_nchars >= 2 &&
+              path[path_nchars - 1] == L'\\' &&
+              path[path_nchars - 2] != L':')
+       {
+               path[--path_nchars] = L'\0';
+       }
+
        params->capture_root_nchars = path_nchars;
 
        memset(&state, 0, sizeof(state));