- /* Pre-allocate the new lookup table entries that will be needed. This
- * way, it's not possible to run out of memory part-way through
- * modifying the lookup table of the destination WIM. */
- for_lookup_table_entry(src_wim->lookup_table, lte_zero_out_refcnt, NULL);
- src_imd = wim_get_current_image_metadata(src_wim);
- INIT_LIST_HEAD(<e_list_head);
- image_for_each_inode(inode, src_imd) {
- ret = inode_allocate_needed_ltes(inode,
- src_wim->lookup_table,
- dest_wim->lookup_table,
- <e_list_head);
+ DEBUG("Exporting image %d from \"%"TS"\"",
+ image, src_wim->filename);
+
+ /* Determine destination image name and description. */
+
+ if (export_flags & WIMLIB_EXPORT_FLAG_NO_NAMES) {
+ next_dest_name = T("");
+ } else if (dest_name) {
+ next_dest_name = dest_name;
+ } else {
+ next_dest_name = wimlib_get_image_name(src_wim,
+ image);
+ }
+
+ DEBUG("Using name \"%"TS"\"", next_dest_name);
+
+ if (export_flags & WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS) {
+ next_dest_description = T("");
+ } else if (dest_description) {
+ next_dest_description = dest_description;
+ } else {
+ next_dest_description = wimlib_get_image_description(
+ src_wim, image);
+ }
+
+ DEBUG("Using description \"%"TS"\"", next_dest_description);
+
+ /* Check for name conflict. */
+ if (wimlib_image_name_in_use(dest_wim, next_dest_name)) {
+ ERROR("There is already an image named \"%"TS"\" "
+ "in the destination WIM", next_dest_name);
+ ret = WIMLIB_ERR_IMAGE_NAME_COLLISION;
+ goto out_rollback;
+ }
+
+ /* Load metadata for source image into memory. */
+ ret = select_wim_image(src_wim, image);