X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fxml.c;h=a214f35f0f92647194be7df1715ea85ac74d8a80;hp=ee75e1755109c5f96fe8b2da0bb7055e6a75163f;hb=4f9947253f6a08f4a922d3efe0880e3039b3eb5e;hpb=393e8e46f87e6119f85b7fc9910624f567c5a34b diff --git a/src/xml.c b/src/xml.c index ee75e175..a214f35f 100644 --- a/src/xml.c +++ b/src/xml.c @@ -1101,7 +1101,8 @@ int read_xml_data(FILE *fp, const struct resource_entry *res, u8 **xml_data_ret, xmlNode *root; int ret; - DEBUG("XML data is %"PRIu64" bytes long.\n", (u64)res->size); + DEBUG("XML data is %"PRIu64" bytes at offset %"PRIu64"\n", + (u64)res->size, res->offset); if (resource_is_compressed(res)) { ERROR("XML data is supposed to be uncompressed!\n"); @@ -1181,14 +1182,18 @@ err0: /* * Writes XML data to a WIM file. + * + * If @total_bytes is non-zero, it specifies what to write to the TOTALBYTES + * element in the XML data. If zero, TOTALBYTES is given the default value of + * the offset of the XML data. */ -int write_xml_data(const struct wim_info *wim_info, int image, FILE *out) +int write_xml_data(const struct wim_info *wim_info, int image, FILE *out, + u64 total_bytes) { xmlBuffer *buf; xmlTextWriter *writer; char *utf16_str; int ret; - off_t total_bytes; int num_images; int i; const xmlChar *content; @@ -1201,13 +1206,15 @@ int write_xml_data(const struct wim_info *wim_info, int image, FILE *out) image <= wim_info->num_images)); /* The contents of the element in the XML data, under the - * element not the element, is the size of the WIM file - * excluding the XML data and integrity table. Which is the current - * offset, since the XML data goes at the end of the WIM file before the - * integrity table. */ - total_bytes = ftello(out); - if (total_bytes == -1) - return WIMLIB_ERR_WRITE; + * element not the element, is (for non-spit WIMs) the + * size of the WIM file excluding the XML data and integrity table, + * which is the current offset, since the XML data goes at the end of + * the WIM file before the integrity table. */ + if (total_bytes == 0) { + total_bytes = ftello(out); + if (total_bytes == (u64)-1) + return WIMLIB_ERR_WRITE; + } DEBUG("Creating XML buffer and text writer\n"); buf = xmlBufferCreate();