]> wimlib.net Git - wimlib/blobdiff - src/xml.c
imagex-optimize: --recompress
[wimlib] / src / xml.c
index a8fa087ef71ccc7c35566ec2e1b9590062e801b0..f9e93fc36c1b6d6fedcdfc2ca3a4f192fb118384 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -1065,7 +1065,6 @@ static int calculate_dentry_statistics(struct dentry *dentry, void *arg)
 void xml_update_image_info(WIMStruct *w, int image)
 {
        struct image_info *image_info;
-       struct dentry *root;
        char *flags_save;
 
        DEBUG("Updating the image info for image %d", image);
@@ -1140,11 +1139,8 @@ out_free_wim_info:
  * */
 void print_image_info(const struct wim_info *wim_info, int image)
 {
-       uint i;
        const struct image_info *image_info;
        const char *desc;
-       int start;
-       int end;
        time_t time;
        char *p;
 
@@ -1291,7 +1287,7 @@ out_cleanup_parser:
  * the offset of the XML data.
  */
 int write_xml_data(const struct wim_info *wim_info, int image, FILE *out,
-                  u64 total_bytes)
+                  u64 total_bytes, struct resource_entry *out_res_entry)
 {
        xmlBuffer     *buf;
        xmlTextWriter *writer;
@@ -1301,11 +1297,16 @@ int write_xml_data(const struct wim_info *wim_info, int image, FILE *out,
        size_t len;
        size_t utf16_len;
        size_t bytes_written;
+       off_t start_offset, end_offset;
 
        wimlib_assert(image == WIM_ALL_IMAGES ||
                        (wim_info != NULL && image >= 1 &&
                         image <= wim_info->num_images));
 
+       start_offset = ftello(out);
+       if (start_offset == -1)
+               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-spit WIMs) the
         * size of the WIM file excluding the XML data and integrity table,
@@ -1394,6 +1395,16 @@ int write_xml_data(const struct wim_info *wim_info, int image, FILE *out,
 
        DEBUG("Cleaning up.");
 
+       end_offset = ftello(out);
+       if (end_offset == -1) {
+               ret = WIMLIB_ERR_WRITE;
+               goto out_free_utf16_str;
+       }
+
+       out_res_entry->offset        = start_offset;
+       out_res_entry->size          = end_offset - start_offset;
+       out_res_entry->original_size = end_offset - start_offset;
+       out_res_entry->flags         = WIM_RESHDR_FLAG_METADATA;
        ret = 0;
 out_free_utf16_str:
        FREE(utf16_str);