]> wimlib.net Git - wimlib/blobdiff - src/xml.c
NEWS
[wimlib] / src / xml.c
index 12bf1a84967efb6ee8589b447e1ce035755532ee..a214f35f0f92647194be7df1715ea85ac74d8a80 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -395,9 +395,15 @@ static int xml_read_image_info(xmlNode *image_node,
                        return ret;
        }
        if (!image_info->name) {
-               ERROR("Image with index %"PRIu64" has no name\n", 
+               WARNING("Image with index %"PRIu64" has no name\n", 
                                        image_info->index);
-               return WIMLIB_ERR_XML;
+               image_info->name = MALLOC(1);
+               if (!image_info->name) {
+                       ERROR("Out of memory!\n");
+                       return WIMLIB_ERR_NOMEM;
+               }
+               image_info->name[0] = '\0';
+               return 0;
        }
        
        return 0;
@@ -1034,7 +1040,6 @@ void print_image_info(const struct wim_info *wim_info, int image)
        time_t ctime;
        time_t mtime;
 
-       DEBUG("Printing the image info for image %d\n", image);
 
        if (image == WIM_ALL_IMAGES) {
                for (i = 1; i <= wim_info->num_images; i++)
@@ -1096,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");
@@ -1176,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;
@@ -1196,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 <TOTALBYTES> element in the XML data, under the
-        * <WIM> element not the <IMAGE> 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;
+        * <WIM> element not the <IMAGE> 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();