wim->in_fd.fd = -1;
wim->out_fd.fd = -1;
}
+ INIT_LIST_HEAD(&wim->subwims);
return wim;
}
return WIMLIB_ERR_INVALID_IMAGE;
}
- if (wim->hdr.part_number != 1) {
- ERROR("Cannot select an image from a non-first part of a split WIM");
- return WIMLIB_ERR_SPLIT_UNSUPPORTED;
+ if (!wim_has_metadata(wim)) {
+ ERROR("\"%"TS"\" does not contain metadata resources!", wim->filename);
+ if (wim->hdr.part_number != 1)
+ ERROR("Specify the first part of the split WIM instead.");
+ return WIMLIB_ERR_METADATA_NOT_FOUND;
}
/* If a valid image is currently selected, it can be freed if it is not
WIMLIBAPI int
wimlib_print_metadata(WIMStruct *wim, int image)
{
- if (wim->hdr.part_number != 1) {
- ERROR("Cannot show the metadata from part %hu of a %hu-part split WIM!",
- wim->hdr.part_number, wim->hdr.total_parts);
- ERROR("Select the first part of the split WIM to see the metadata.");
- return WIMLIB_ERR_SPLIT_UNSUPPORTED;
- }
return for_image(wim, image, image_print_metadata);
}
if (ret)
return ret;
- if (which & WIMLIB_CHANGE_GUID)
+ if (which & WIMLIB_CHANGE_GUID) {
memcpy(wim->hdr.guid, info->guid, WIM_GID_LEN);
+ wim->guid_set_explicitly = 1;
+ }
if (which & WIMLIB_CHANGE_BOOT_INDEX) {
if (info->boot_index > wim->hdr.image_count) {
WIMLIBAPI void
wimlib_free(WIMStruct *wim)
{
- DEBUG("Freeing WIMStruct");
-
if (!wim)
return;
+
+ DEBUG("Freeing WIMStruct (filename=\"%"TS"\", image_count=%u)",
+ wim->filename, wim->hdr.image_count);
+
+ while (!list_empty(&wim->subwims)) {
+ WIMStruct *subwim;
+
+ subwim = list_entry(wim->subwims.next, WIMStruct, subwim_node);
+ list_del(&subwim->subwim_node);
+ DEBUG("Freeing subwim.");
+ wimlib_free(subwim);
+ }
+
if (filedes_valid(&wim->in_fd))
filedes_close(&wim->in_fd);
if (filedes_valid(&wim->out_fd))
filedes_close(&wim->out_fd);
+
free_lookup_table(wim->lookup_table);
FREE(wim->filename);
FREE(wim->image_metadata);
}
FREE(wim);
- DEBUG("Freed WIMStruct");
}
static bool
wimlib_global_init(int init_flags)
{
static bool already_inited = false;
+ int ret;
if (already_inited)
return 0;
#endif
}
#ifdef __WIN32__
- win32_global_init(init_flags);
+ ret = win32_global_init(init_flags);
+ if (ret)
+ return ret;
+#else
+ ret = 0;
#endif
already_inited = true;
- return 0;
+ return ret;
}
/* API function documented in wimlib.h */