- if (w->hdr.part_number != 1) {
- ERROR("Cannot list the files from part %hu of a %hu-part split WIM!",
- w->hdr.part_number, w->hdr.total_parts);
- ERROR("Select the first part of the split WIM if you'd like to list the files.");
- return WIMLIB_ERR_SPLIT_UNSUPPORTED;
+ memset(info, 0, sizeof(struct wimlib_wim_info));
+ memcpy(info->guid, wim->hdr.guid, WIMLIB_GUID_LEN);
+ info->image_count = wim->hdr.image_count;
+ info->boot_index = wim->hdr.boot_idx;
+ info->wim_version = wim->hdr.wim_version;
+ info->chunk_size = wim->chunk_size;
+ info->part_number = wim->hdr.part_number;
+ info->total_parts = wim->hdr.total_parts;
+ info->compression_type = wim->compression_type;
+ info->total_bytes = wim_info_get_total_bytes(wim->wim_info);
+ info->has_integrity_table = wim_has_integrity_table(wim);
+ info->opened_from_file = (wim->filename != NULL);
+ info->is_readonly = (wim->hdr.flags & WIM_HDR_FLAG_READONLY) ||
+ (wim->hdr.total_parts != 1) ||
+ (wim->filename && taccess(wim->filename, W_OK));
+ info->has_rpfix = (wim->hdr.flags & WIM_HDR_FLAG_RP_FIX) != 0;
+ info->is_marked_readonly = (wim->hdr.flags & WIM_HDR_FLAG_READONLY) != 0;
+ info->write_in_progress = (wim->hdr.flags & WIM_HDR_FLAG_WRITE_IN_PROGRESS) != 0;
+ info->metadata_only = (wim->hdr.flags & WIM_HDR_FLAG_METADATA_ONLY) != 0;
+ info->resource_only = (wim->hdr.flags & WIM_HDR_FLAG_RESOURCE_ONLY) != 0;
+ info->spanned = (wim->hdr.flags & WIM_HDR_FLAG_SPANNED) != 0;
+ info->pipable = wim_is_pipable(wim);
+ return 0;
+}
+
+/* API function documented in wimlib.h */
+WIMLIBAPI int
+wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info, int which)
+{
+ int ret;
+
+ if (which & WIMLIB_CHANGE_READONLY_FLAG) {
+ if (info->is_marked_readonly)
+ wim->hdr.flags |= WIM_HDR_FLAG_READONLY;
+ else
+ wim->hdr.flags &= ~WIM_HDR_FLAG_READONLY;