]> wimlib.net Git - wimlib/blobdiff - src/win32_capture.c
Improve write streams performance and handling of joins
[wimlib] / src / win32_capture.c
index 43c09e9ef75751af0921529a035aaeb1b823abd3..9b16796a5e4bb6f0ac6e0e9fde4f86bbf339f580 100644 (file)
@@ -757,10 +757,7 @@ win32_capture_stream(const wchar_t *path,
        if (is_named_stream) {
                spath_nchars += 1 + stream_name_nchars;
                colonchar = L":";
-               if (path_num_chars == 1 &&
-                   path[0] != L'/' &&
-                   path[0] != L'\\')
-               {
+               if (path_num_chars == 1 && !is_any_path_separator(path[0])) {
                        spath_nchars += 2;
                        static const wchar_t _relpath_prefix[] =
                                {L'.', OS_PREFERRED_PATH_SEPARATOR, L'\0'};
@@ -790,7 +787,7 @@ win32_capture_stream(const wchar_t *path,
                        goto out_free_spath;
                lte->resource_entry.original_size = encrypted_size;
        } else {
-               lte->resource_location = RESOURCE_WIN32;
+               lte->resource_location = RESOURCE_IN_FILE_ON_DISK;
                lte->resource_entry.original_size = (u64)dat->StreamSize.QuadPart;
        }
 
@@ -1145,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; "
@@ -1169,7 +1167,7 @@ win32_build_dentry_tree(struct wim_dentry **root_ret,
        if (ret)
                return ret;
 
-       win32_get_vol_flags(root_disk_path, &vol_flags);
+       win32_get_vol_flags(root_disk_path, &vol_flags, NULL);
 
        /* WARNING: There is no check for overflow later when this buffer is
         * being used!  But it's as long as the maximum path length understood
@@ -1192,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);
@@ -1201,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);