+ *total_parts_ret = info.total_parts;
+ return info.part_number;
+}
+
+/* API function documented in wimlib.h */
+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;
+}
+
+/* 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;
+ }
+
+ 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 > 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;
+ }
+ return 0;
+}
+
+/* API function documented in wimlib.h */
+WIMLIBAPI int
+wimlib_set_boot_idx(WIMStruct *wim, int boot_idx)
+{
+ struct wimlib_wim_info info;
+
+ info.boot_index = boot_idx;
+ return wimlib_set_wim_info(wim, &info, WIMLIB_CHANGE_BOOT_INDEX);
+}
+
+static int
+do_open_wim(const tchar *filename, struct filedes *fd_ret)
+{
+ int raw_fd;
+
+ raw_fd = topen(filename, O_RDONLY | O_BINARY);
+ if (raw_fd < 0) {
+ ERROR_WITH_ERRNO("Can't open \"%"TS"\" read-only", filename);
+ return WIMLIB_ERR_OPEN;
+ }
+ filedes_init(fd_ret, raw_fd);
+ return 0;