]> wimlib.net Git - wimlib/commitdiff
Win32: Correctly handle pattern matching with \\?\-prefixed paths
authorEric Biggers <ebiggers3@gmail.com>
Fri, 19 Jul 2013 01:59:00 +0000 (20:59 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Fri, 19 Jul 2013 02:00:24 +0000 (21:00 -0500)
The switch to using \\?\-prefixed paths made excluding files stop working
on Windows.  Fix it.

include/wimlib.h
include/wimlib/capture.h
src/win32_capture.c

index 75fde577b1f68c936d536bd46c5f58ee3ac78846..d80089c6d95f02f99fbf14e28d927031a7e13552 100644 (file)
@@ -617,7 +617,7 @@ struct wimlib_capture_config {
        struct wimlib_pattern_list reserved2;
 
        /** Library internal use only. */
-       const wimlib_tchar *_prefix;
+       wimlib_tchar *_prefix;
 
        /** Library internal use only. */
        size_t _prefix_num_tchars;
index b60c5c85a348bfc6aaea477fb72d294f5e9e2b33..8b67c949c4b2870fb5c01776b3fda78b16e0cf78 100644 (file)
@@ -47,7 +47,7 @@ struct add_image_params {
 
        /* Pointer to the capture configuration, which indicates whether any
         * files should be excluded from capture or not. */
-       const struct wimlib_capture_config *config;
+       struct wimlib_capture_config *config;
 
        /* Flags that affect the capture operation (WIMLIB_ADD_FLAG_*) */
        int add_flags;
index afb38e30a7ce497a49d2656e770cdaa5c2217613..2e501dba3bd5b48480fc4ee53bf40f28fcb409e3 100644 (file)
@@ -1142,6 +1142,7 @@ win32_build_dentry_tree(struct wim_dentry **root_ret,
        struct win32_capture_state state;
        unsigned vol_flags;
        DWORD dret;
+       bool need_prefix_free = false;
 
        if (!win32func_FindFirstStreamW) {
                WARNING("Running on Windows XP or earlier; "
@@ -1189,6 +1190,18 @@ win32_build_dentry_tree(struct wim_dentry **root_ret,
                } else {
                        wmemcpy(path, L"\\\\?\\", 4);
                        path_nchars = 4 + dret;
+                       /* Update pattern prefix */
+                       if (params->config != NULL)
+                       {
+                               params->config->_prefix = TSTRDUP(path);
+                               params->config->_prefix_num_tchars = path_nchars;
+                               if (params->config->_prefix == NULL)
+                               {
+                                       ret = WIMLIB_ERR_NOMEM;
+                                       goto out_free_path;
+                               }
+                               need_prefix_free = true;
+                       }
                }
        } else {
                wmemcpy(path, root_disk_path, path_nchars + 1);
@@ -1198,6 +1211,9 @@ win32_build_dentry_tree(struct wim_dentry **root_ret,
        ret = win32_build_dentry_tree_recursive(root_ret, path,
                                                path_nchars, params,
                                                &state, vol_flags);
+       if (need_prefix_free)
+               FREE(params->config->_prefix);
+out_free_path:
        FREE(path);
        if (ret == 0)
                win32_do_capture_warnings(&state, params->add_flags);