X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fadd_image.c;h=cf89e695dc986389ad7dd5a3d0da72c0f4c6ac66;hb=541b65d79e0c73238a25e2c2661711d8593d0684;hp=ab4adc97176e459bc38f27406a4d186b6b92df29;hpb=b5d427e440402aff987a060ff6ceefcb97117fa4;p=wimlib diff --git a/src/add_image.c b/src/add_image.c index ab4adc97..cf89e695 100644 --- a/src/add_image.c +++ b/src/add_image.c @@ -452,7 +452,7 @@ destroy_capture_config(struct capture_config *config) static int pattern_list_add_pattern(struct pattern_list *list, const mbchar *pattern) { - const char **pats; + const mbchar **pats; if (list->num_pats >= list->num_allocated_pats) { pats = REALLOC(list->pats, sizeof(list->pats[0]) * (list->num_allocated_pats + 8)); @@ -584,8 +584,8 @@ static bool match_pattern(const mbchar *path, const struct pattern_list *list) { for (size_t i = 0; i < list->num_pats; i++) { - const char *pat = list->pats[i]; - const char *string; + const mbchar *pat = list->pats[i]; + const mbchar *string; if (pat[0] == '/') /* Absolute path from root of capture */ string = path; @@ -784,6 +784,7 @@ new_filler_directory(const mbchar *name, struct wim_dentry **dentry_ret) * will be assigned later by assign_inode_numbers(). */ dentry->d_inode->i_resolved = 1; dentry->d_inode->i_attributes = FILE_ATTRIBUTE_DIRECTORY; + *dentry_ret = dentry; } return ret; } @@ -840,7 +841,7 @@ static int attach_branch(struct wim_dentry **root_p, struct wim_dentry *branch, mbchar *target_path) { - char *slash; + mbchar *slash; struct wim_dentry *dentry, *parent, *target; int ret; @@ -1009,68 +1010,62 @@ wimlib_add_image_multisource(WIMStruct *w, } DEBUG("Building dentry tree."); - if (num_sources == 0) { - ret = new_filler_directory("", &root_dentry); + root_dentry = NULL; + + for (size_t i = 0; i < num_sources; i++) { + int flags; + union wimlib_progress_info progress; + + DEBUG("Building dentry tree for source %zu of %zu " + "(\"%s\" => \"%s\")", i + 1, num_sources, + sources[i].fs_source_path, + sources[i].wim_target_path); + if (progress_func) { + memset(&progress, 0, sizeof(progress)); + progress.scan.source = sources[i].fs_source_path; + progress.scan.wim_target_path = sources[i].wim_target_path; + progress_func(WIMLIB_PROGRESS_MSG_SCAN_BEGIN, &progress); + } + ret = capture_config_set_prefix(&config, + sources[i].fs_source_path); if (ret) - goto out_free_security_data; - } else { - size_t i; - - #ifdef __WIN32__ - win32_acquire_capture_privileges(); - #endif + goto out_free_dentry_tree; + flags = add_image_flags | WIMLIB_ADD_IMAGE_FLAG_SOURCE; + if (!*sources[i].wim_target_path) + flags |= WIMLIB_ADD_IMAGE_FLAG_ROOT; + ret = (*capture_tree)(&branch, sources[i].fs_source_path, + w->lookup_table, sd, + &config, + flags, + progress_func, extra_arg); + if (ret) { + ERROR("Failed to build dentry tree for `%s'", + sources[i].fs_source_path); + goto out_free_dentry_tree; + } + if (branch) { + /* Use the target name, not the source name, for + * the root of each branch from a capture + * source. (This will also set the root dentry + * of the entire image to be unnamed.) */ + ret = set_dentry_name(branch, + path_basename(sources[i].wim_target_path)); + if (ret) + goto out_free_branch; - root_dentry = NULL; - i = 0; - do { - int flags; - union wimlib_progress_info progress; - - DEBUG("Building dentry tree for source %zu of %zu " - "(\"%s\" => \"%s\")", i + 1, num_sources, - sources[i].fs_source_path, - sources[i].wim_target_path); - if (progress_func) { - memset(&progress, 0, sizeof(progress)); - progress.scan.source = sources[i].fs_source_path; - progress.scan.wim_target_path = sources[i].wim_target_path; - progress_func(WIMLIB_PROGRESS_MSG_SCAN_BEGIN, &progress); - } - ret = capture_config_set_prefix(&config, - sources[i].fs_source_path); + ret = attach_branch(&root_dentry, branch, + sources[i].wim_target_path); if (ret) - goto out_free_dentry_tree; - flags = add_image_flags | WIMLIB_ADD_IMAGE_FLAG_SOURCE; - if (!*sources[i].wim_target_path) - flags |= WIMLIB_ADD_IMAGE_FLAG_ROOT; - ret = (*capture_tree)(&branch, sources[i].fs_source_path, - w->lookup_table, sd, - &config, - flags, - progress_func, extra_arg); - if (ret) { - ERROR("Failed to build dentry tree for `%s'", - sources[i].fs_source_path); - goto out_free_dentry_tree; - } - if (branch) { - /* Use the target name, not the source name, for - * the root of each branch from a capture - * source. (This will also set the root dentry - * of the entire image to be unnamed.) */ - ret = set_dentry_name(branch, - path_basename(sources[i].wim_target_path)); - if (ret) - goto out_free_branch; - - ret = attach_branch(&root_dentry, branch, - sources[i].wim_target_path); - if (ret) - goto out_free_branch; - } - if (progress_func) - progress_func(WIMLIB_PROGRESS_MSG_SCAN_END, &progress); - } while (++i != num_sources); + goto out_free_branch; + } + if (progress_func) + progress_func(WIMLIB_PROGRESS_MSG_SCAN_END, &progress); + } + + if (root_dentry == NULL) { + ret = new_filler_directory("" , &root_dentry); + if (ret) + goto out_free_dentry_tree; } DEBUG("Calculating full paths of dentries."); @@ -1113,9 +1108,6 @@ out_free_security_data: out_destroy_capture_config: destroy_capture_config(&config); out: -#ifdef __WIN32__ - win32_release_capture_privileges(); -#endif return ret; } @@ -1131,7 +1123,7 @@ wimlib_add_image(WIMStruct *w, if (!source || !*source) return WIMLIB_ERR_INVALID_PARAM; - char *fs_source_path = STRDUP(source); + mbchar *fs_source_path = STRDUP(source); int ret; struct wimlib_capture_source capture_src = { .fs_source_path = fs_source_path,