From: Eric Biggers Date: Fri, 19 Jul 2013 01:59:00 +0000 (-0500) Subject: Win32: Correctly handle pattern matching with \\?\-prefixed paths X-Git-Tag: v1.5.0~90 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=8d6441232a9080d8f7d9db839c4c3e17349c4a77 Win32: Correctly handle pattern matching with \\?\-prefixed paths The switch to using \\?\-prefixed paths made excluding files stop working on Windows. Fix it. --- diff --git a/include/wimlib.h b/include/wimlib.h index 75fde577..d80089c6 100644 --- a/include/wimlib.h +++ b/include/wimlib.h @@ -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; diff --git a/include/wimlib/capture.h b/include/wimlib/capture.h index b60c5c85..8b67c949 100644 --- a/include/wimlib/capture.h +++ b/include/wimlib/capture.h @@ -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; diff --git a/src/win32_capture.c b/src/win32_capture.c index afb38e30..2e501dba 100644 --- a/src/win32_capture.c +++ b/src/win32_capture.c @@ -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);