lookup_table_remove(lt, imd->metadata_lte);
}
-/*
+/*
* Recursively builds a dentry tree from a directory tree on disk, outside the
* WIM file.
*
* modified if successful. NULL if the file or directory was
* excluded from capture.
*
- * @root_disk_path: The path to the root of the directory tree on disk.
+ * @root_disk_path: The path to the root of the directory tree on disk.
*
* @lookup_table: The lookup table for the WIM file. For each file added to the
- * dentry tree being built, an entry is added to the lookup table,
+ * dentry tree being built, an entry is added to the lookup table,
* unless an identical stream is already in the lookup table.
* These lookup table entries that are added point to the path of
* the file on disk.
return WIMLIB_ERR_STAT;
}
- if ((add_flags & WIMLIB_ADD_IMAGE_FLAG_ROOT) &&
+ if ((add_flags & WIMLIB_ADD_IMAGE_FLAG_ROOT) &&
!S_ISDIR(root_stbuf.st_mode)) {
ERROR("`%s' is not a directory", root_disk_path);
return WIMLIB_ERR_NOTDIR;
if (ret != 0)
break;
if (child)
- link_dentry(child, root);
+ dentry_add_child(root, child);
}
closedir(dir);
} else if (dentry_is_symlink(root)) { /* Archiving a symbolic link */
char deref_name_buf[4096];
ssize_t deref_name_len;
-
+
deref_name_len = readlink(root_disk_path, deref_name_buf,
sizeof(deref_name_buf) - 1);
if (deref_name_len >= 0) {
return 0;
}
-/*
+/*
* This function takes in a dentry that was previously located only in image(s)
* in @src_wim, but now is being added to @dest_wim. For each stream associated
* with the dentry, if there is already a lookup table entry for that stream in
/*
* Adds an image (given by its dentry tree) to the image metadata array of a WIM
* file, adds an entry to the lookup table for the image metadata, updates the
- * image count in the header, and selects the new image.
+ * image count in the header, and selects the new image.
*
* Does not update the XML data.
*
if (!imd) {
ERROR("Failed to allocate memory for new image metadata array");
- return WIMLIB_ERR_NOMEM;
+ goto err;
}
- memcpy(imd, w->image_metadata,
+ memcpy(imd, w->image_metadata,
w->hdr.image_count * sizeof(struct image_metadata));
-
+
metadata_lte = new_lookup_table_entry();
if (!metadata_lte)
- goto out_free_imd;
+ goto err_free_imd;
metadata_lte->resource_entry.flags = WIM_RESHDR_FLAG_METADATA;
random_hash(metadata_lte->hash);
ret = select_wim_image(w, w->hdr.image_count);
wimlib_assert(ret == 0);
return ret;
-out_free_metadata_lte:
- FREE(metadata_lte);
-out_free_imd:
+err_free_imd:
FREE(imd);
+err:
return WIMLIB_ERR_NOMEM;
}
/*
* Copies an image, or all the images, from a WIM file, into another WIM file.
*/
-WIMLIBAPI int wimlib_export_image(WIMStruct *src_wim,
- int src_image,
- WIMStruct *dest_wim,
- const char *dest_name,
- const char *dest_description,
+WIMLIBAPI int wimlib_export_image(WIMStruct *src_wim,
+ int src_image,
+ WIMStruct *dest_wim,
+ const char *dest_name,
+ const char *dest_description,
int flags,
WIMStruct **additional_swms,
unsigned num_additional_swms)
/* multi-image export. */
- if ((flags & WIMLIB_EXPORT_FLAG_BOOT) &&
+ if ((flags & WIMLIB_EXPORT_FLAG_BOOT) &&
(src_wim->hdr.boot_idx == 0))
{
/* Specifying the boot flag on a multi-image
if (i != src_wim->hdr.boot_idx)
export_flags &= ~WIMLIB_EXPORT_FLAG_BOOT;
- ret = wimlib_export_image(src_wim, i, dest_wim,
+ ret = wimlib_export_image(src_wim, i, dest_wim,
NULL, NULL,
export_flags,
additional_swms,
return ret;
}
return 0;
+ } else if (src_wim->hdr.image_count == 1) {
+ src_image = 1;
} else {
- src_image = 1;
+ return 0;
}
}
return ret;
}
-/*
- * Deletes an image from the WIM.
+/*
+ * Deletes an image from the WIM.
*/
WIMLIBAPI int wimlib_delete_image(WIMStruct *w, int image)
{
FREE(config_str);
return WIMLIB_ERR_NOMEM;
}
-
+
memcpy(config_str, _config_str, config_len);
next_p = config_str;
config->config_str = config_str;
ret = WIMLIB_ERR_INVALID_CAPTURE_CONFIG;
goto out_destroy;
}
-
+
next_p = eol + 1;
bytes_remaining -= (next_p - p);
if (eol == p)
&& path[config->prefix_len] == '/')
path += config->prefix_len;
}
- return match_pattern(path, basename, &config->exclusion_list) &&
+ return match_pattern(path, basename, &config->exclusion_list) &&
!match_pattern(path, basename, &config->exclusion_exception);
}
const char *config_str, size_t config_len,
int flags,
int (*capture_tree)(struct dentry **, const char *,
- struct lookup_table *,
+ struct lookup_table *,
struct wim_security_data *,
const struct capture_config *,
int, void *),
sd->refcnt = 1;
DEBUG("Building dentry tree.");
+ if (flags & WIMLIB_ADD_IMAGE_FLAG_SHOW_PROGRESS) {
+ printf("Scanning `%s'...\n", dir);
+ }
ret = (*capture_tree)(&root_dentry, dir, w->lookup_table, sd,
&config, flags | WIMLIB_ADD_IMAGE_FLAG_ROOT,
extra_arg);
goto out_destroy_imd;
if (flags & WIMLIB_ADD_IMAGE_FLAG_BOOT)
- wimlib_set_boot_idx(w, w->hdr.image_count);
+ w->hdr.boot_idx = w->hdr.image_count;
return 0;
out_destroy_imd:
/*
* Adds an image to a WIM file from a directory tree on disk.
*/
-WIMLIBAPI int wimlib_add_image(WIMStruct *w, const char *dir,
+WIMLIBAPI int wimlib_add_image(WIMStruct *w, const char *dir,
const char *name, const char *config_str,
size_t config_len, int flags)
{