- wimlib_assert(image == WIMLIB_ALL_IMAGES ||
- (wim_info != NULL && image >= 1 &&
- image <= wim_info->num_images));
-
- start_offset = ftello(out);
- if (start_offset == -1)
- return WIMLIB_ERR_WRITE;
-
- DEBUG("Writing XML data for image %d at offset %"PRIu64,
- image, start_offset);
-
- /* 2 bytes endianness marker for UTF-16LE. This is _required_ for WIM
- * XML data. */
- if ((putc(0xff, out)) == EOF || (putc(0xfe, out) == EOF)) {
- ERROR_WITH_ERRNO("Error writing XML data");
- return WIMLIB_ERR_WRITE;
- }
-
- /* The contents of the <TOTALBYTES> element in the XML data, under the
- * <WIM> element (not the <IMAGE> element), is for non-split WIMs the
- * size of the WIM file excluding the XML data and integrity table.
- * This should be equal to the current position in the output stream,
- * since the XML data and integrity table are the last elements of the
- * WIM.
- *
- * For split WIMs, <TOTALBYTES> takes into account the entire WIM, not
- * just the current part. In that case, @total_bytes should be passed
- * in to this function. */
- if (total_bytes == 0)
- total_bytes = start_offset;