-/*
- * Writes the header for a WIM file.
- *
- * @hdr: A pointer to a struct wim_header structure that describes the header.
- * @out: The FILE* for the output file, positioned at the appropriate
- * place (the beginning of the file).
- * @return: Zero on success, nonzero on failure.
- */
-int
-write_header(const struct wim_header *hdr, FILE *out_fp)
-{
- u8 buf[WIM_HEADER_DISK_SIZE];
- u8 *p;
- DEBUG("Writing WIM header.");
-
- p = put_bytes(buf, WIM_MAGIC_LEN, wim_magic_chars);
- p = put_u32(p, WIM_HEADER_DISK_SIZE);
- p = put_u32(p, WIM_VERSION);
- p = put_u32(p, hdr->flags);
- p = put_u32(p, (hdr->flags & WIM_HDR_FLAG_COMPRESSION) ?
- WIM_CHUNK_SIZE : 0);
- /* byte 24 */
-
- p = put_bytes(p, WIM_GID_LEN, hdr->guid);
- p = put_u16(p, hdr->part_number);
-
- /* byte 40 */
-
- p = put_u16(p, hdr->total_parts);
- p = put_u32(p, hdr->image_count);
- p = put_resource_entry(p, &hdr->lookup_table_res_entry);
- p = put_resource_entry(p, &hdr->xml_res_entry);
- p = put_resource_entry(p, &hdr->boot_metadata_res_entry);
- p = put_u32(p, hdr->boot_idx);
- p = put_resource_entry(p, &hdr->integrity);
- memset(p, 0, WIM_UNUSED_LEN);
- if (fwrite(buf, 1, sizeof(buf), out_fp) != sizeof(buf)) {
- ERROR_WITH_ERRNO("Failed to write WIM header");
- return WIMLIB_ERR_WRITE;