+ if (!wim)
+ return WIMLIB_ERR_INVALID_PARAM;
+
+ if (verify_flags)
+ return WIMLIB_ERR_INVALID_PARAM;
+
+ /* Verify the images */
+
+ if (wim_has_metadata(wim)) {
+
+ memset(&progress, 0, sizeof(progress));
+ progress.verify_image.wimfile = wim->filename;
+ progress.verify_image.total_images = wim->hdr.image_count;
+
+ for (int i = 1; i <= wim->hdr.image_count; i++) {
+
+ progress.verify_image.current_image = i;
+
+ ret = call_progress(wim->progfunc, WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE,
+ &progress, wim->progctx);
+ if (ret)
+ return ret;
+
+ ret = select_wim_image(wim, i);
+ if (ret)
+ return ret;
+
+ ret = verify_file_data_present(wim_get_current_image_metadata(wim),
+ wim->blob_table);
+ if (ret)
+ return ret;
+
+ ret = call_progress(wim->progfunc, WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE,
+ &progress, wim->progctx);
+ if (ret)
+ return ret;
+ }
+ } else {
+ WARNING("\"%"TS"\" does not contain image metadata. Skipping image verification.",
+ wim->filename);
+ }
+
+ /* Verify the blobs: SHA-1 message digests must match */
+
+ for_blob_in_table(wim->blob_table, append_blob_to_list, &blob_list);
+
+ memset(&progress, 0, sizeof(progress));
+
+ progress.verify_streams.wimfile = wim->filename;
+ list_for_each_entry(blob, &blob_list, extraction_list) {
+ progress.verify_streams.total_streams++;
+ progress.verify_streams.total_bytes += blob->size;
+ }
+
+ ctx.progfunc = wim->progfunc;
+ ctx.progctx = wim->progctx;
+ ctx.progress = &progress;
+ ctx.next_progress = 0;
+
+ ret = call_progress(ctx.progfunc, WIMLIB_PROGRESS_MSG_VERIFY_STREAMS,
+ ctx.progress, ctx.progctx);