- if (boot_idx < 0 || boot_idx > w->hdr.image_count)
- return WIMLIB_ERR_INVALID_IMAGE;
- w->hdr.boot_idx = boot_idx;
- if (boot_idx == 0) {
- memset(&w->hdr.boot_metadata_res_entry, 0,
- sizeof(struct resource_entry));
- } else {
- memcpy(&w->hdr.boot_metadata_res_entry,
- &w->image_metadata[
- boot_idx - 1].metadata_lte->resource_entry,
- sizeof(struct resource_entry));
+ struct wimlib_wim_info info;
+
+ wimlib_get_wim_info((WIMStruct*)wim, &info);
+ return info.compression_type;
+}
+
+/* Deprecated */
+WIMLIBAPI int
+wimlib_get_num_images(const WIMStruct *wim)
+{
+ struct wimlib_wim_info info;
+
+ wimlib_get_wim_info((WIMStruct*)wim, &info);
+ return info.image_count;
+}
+
+/* Deprecated */
+WIMLIBAPI int
+wimlib_get_part_number(const WIMStruct *wim, int *total_parts_ret)
+{
+ struct wimlib_wim_info info;
+
+ wimlib_get_wim_info((WIMStruct*)wim, &info);
+ if (total_parts_ret)
+ *total_parts_ret = info.total_parts;
+ return info.part_number;
+}
+
+/* Deprecated */
+WIMLIBAPI bool
+wimlib_has_integrity_table(const WIMStruct *wim)
+{
+ struct wimlib_wim_info info;
+
+ wimlib_get_wim_info((WIMStruct*)wim, &info);
+ return info.has_integrity_table;
+}
+
+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;
+ }
+
+ if ((which & ~WIMLIB_CHANGE_READONLY_FLAG) == 0)
+ return 0;
+
+ ret = can_modify_wim(wim);
+ if (ret)
+ return ret;
+
+ if (which & WIMLIB_CHANGE_GUID)
+ memcpy(wim->hdr.guid, info->guid, WIM_GID_LEN);
+
+ if (which & WIMLIB_CHANGE_BOOT_INDEX) {
+ if (info->boot_index < 0 || info->boot_index > wim->hdr.image_count)
+ {
+ ERROR("%u is not 0 or a valid image in the WIM to mark as bootable",
+ info->boot_index);
+ return WIMLIB_ERR_INVALID_IMAGE;
+ }
+ wim->hdr.boot_idx = info->boot_index;
+ }
+
+ if (which & WIMLIB_CHANGE_RPFIX_FLAG) {
+ if (info->has_rpfix)
+ wim->hdr.flags |= WIM_HDR_FLAG_RP_FIX;
+ else
+ wim->hdr.flags &= ~WIM_HDR_FLAG_RP_FIX;