* This file is part of wimlib, a library for working with WIM files.
*
* wimlib is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
+ * terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
* any later version.
*
* wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
- * You should have received a copy of the GNU Lesser General Public License
+ * You should have received a copy of the GNU General Public License
* along with wimlib; if not, see http://www.gnu.org/licenses/.
*/
if (dest_lte) {
dest_lte->refcnt++;
} else {
- dest_lte = new_lookup_table_entry();
+ dest_lte = MALLOC(sizeof(struct lookup_table_entry));
if (!dest_lte)
return WIMLIB_ERR_NOMEM;
- dest_lte->resource_location = RESOURCE_IN_WIM;
- dest_lte->wim = src_wim;
- memcpy(&dest_lte->resource_entry,
- &src_lte->resource_entry,
- sizeof(struct resource_entry));
- copy_hash(dest_lte->hash,
- dentry_stream_hash_unresolved(dentry, i));
+ memcpy(dest_lte, src_lte, sizeof(struct lookup_table_entry));
+ dest_lte->part_number = 1;
+ dest_lte->refcnt = 1;
lookup_table_insert(dest_wim->lookup_table, dest_lte);
}
}
WIMStruct *dest_wim,
const char *dest_name,
const char *dest_description,
- int flags)
+ int flags,
+ WIMStruct **additional_swms,
+ unsigned num_additional_swms)
{
int i;
int ret;
struct dentry *root;
struct wim_pair wims;
struct wim_security_data *sd;
+ struct lookup_table *joined_tab, *src_wim_tab_save;
+
+ if (!src_wim || !dest_wim)
+ return WIMLIB_ERR_INVALID_PARAM;
+
+ if (dest_wim->hdr.total_parts != 1) {
+ ERROR("Exporting an image to a split WIM is "
+ "unsupported");
+ return WIMLIB_ERR_SPLIT_UNSUPPORTED;
+ }
if (src_image == WIM_ALL_IMAGES) {
if (src_wim->hdr.image_count > 1) {
ret = wimlib_export_image(src_wim, i, dest_wim,
NULL,
dest_description,
- export_flags);
+ export_flags,
+ additional_swms,
+ num_additional_swms);
if (ret != 0)
return ret;
}
}
}
- ret = wimlib_select_image(src_wim, src_image);
- if (ret != 0) {
- ERROR("Could not select image %d from the WIM `%s' "
- "to export it", src_image, src_wim->filename);
- return ret;
- }
-
if (!dest_name) {
dest_name = wimlib_get_image_name(src_wim, src_image);
DEBUG("Using name `%s' for source image %d",
return WIMLIB_ERR_IMAGE_NAME_COLLISION;
}
+ ret = verify_swm_set(src_wim, additional_swms, num_additional_swms);
+ if (ret != 0)
+ return ret;
+
+ if (num_additional_swms) {
+ ret = new_joined_lookup_table(src_wim, additional_swms,
+ num_additional_swms,
+ &joined_tab);
+ if (ret != 0)
+ return ret;
+ src_wim_tab_save = src_wim->lookup_table;
+ src_wim->lookup_table = joined_tab;
+ }
+
+ ret = wimlib_select_image(src_wim, src_image);
+ if (ret != 0) {
+ ERROR("Could not select image %d from the WIM `%s' "
+ "to export it", src_image, src_wim->filename);
+ goto out;
+ }
/* Cleaning up here on failure would be hard. For example, we could
* fail to allocate memory in add_lte_to_dest_wim(),
* leaving the lookup table entries in the destination WIM in an
* inconsistent state. Until these issues can be resolved,
- * wimlib_export_image() is documented as leaving dest_wim is an
+ * wimlib_export_image() is documented as leaving dest_wim in an
* indeterminate state. */
root = wim_root_dentry(src_wim);
sd = wim_security_data(src_wim);
wims.dest_wim = dest_wim;
ret = for_dentry_in_tree(root, add_lte_to_dest_wim, &wims);
if (ret != 0)
- return ret;
+ goto out;
ret = add_new_dentry_tree(dest_wim, root, sd);
if (ret != 0)
- return ret;
+ goto out;
sd->refcnt++;
if (flags & WIMLIB_EXPORT_FLAG_BOOT) {
dest_wim->hdr.boot_idx = dest_wim->hdr.image_count;
}
- return xml_export_image(src_wim->wim_info, src_image, &dest_wim->wim_info,
- dest_name, dest_description);
+ ret = xml_export_image(src_wim->wim_info, src_image, &dest_wim->wim_info,
+ dest_name, dest_description);
+out:
+ if (num_additional_swms) {
+ free_lookup_table(src_wim->lookup_table);
+ src_wim->lookup_table = src_wim_tab_save;
+ }
+ return ret;
}
/*
int i;
int ret;
+ if (w->hdr.total_parts != 1) {
+ ERROR("Deleting an image from a split WIM is not supported.");
+ return WIMLIB_ERR_SPLIT_UNSUPPORTED;
+ }
+
if (image == WIM_ALL_IMAGES) {
num_images = w->hdr.image_count;
for (i = 1; i <= num_images; i++) {
return WIMLIB_ERR_INVALID_PARAM;
}
+ if (w->hdr.total_parts != 1) {
+ ERROR("Cannot add an image to a split WIM");
+ return WIMLIB_ERR_SPLIT_UNSUPPORTED;
+ }
+
if (wimlib_image_name_in_use(w, name)) {
ERROR("There is already an image named \"%s\" in `%s'",
name, w->filename);