]> wimlib.net Git - wimlib/blobdiff - src/resource.c
New helper: wim_reshdr_to_desc_and_blob()
[wimlib] / src / resource.c
index 74c9bb8b9a9570aa52110139e73cc9a0907982bb..a4cc6c1291c669da3715f51d5132f6dfb03f6349 100644 (file)
@@ -808,8 +808,7 @@ wim_reshdr_to_data(const struct wim_reshdr *reshdr, WIMStruct *wim,
        struct wim_resource_descriptor rdesc;
        struct blob_descriptor blob;
 
-       wim_reshdr_to_desc(reshdr, wim, &rdesc);
-       blob_set_is_located_in_nonsolid_wim_resource(&blob, &rdesc);
+       wim_reshdr_to_desc_and_blob(reshdr, wim, &rdesc, &blob);
 
        return read_blob_into_alloc_buf(&blob, buf_ret);
 }
@@ -824,8 +823,7 @@ wim_reshdr_to_hash(const struct wim_reshdr *reshdr, WIMStruct *wim,
        struct blob_descriptor blob;
        int ret;
 
-       wim_reshdr_to_desc(reshdr, wim, &rdesc);
-       blob_set_is_located_in_nonsolid_wim_resource(&blob, &rdesc);
+       wim_reshdr_to_desc_and_blob(reshdr, wim, &rdesc, &blob);
        blob.unhashed = 1;
 
        ret = sha1_blob(&blob);
@@ -1267,6 +1265,21 @@ wim_reshdr_to_desc(const struct wim_reshdr *reshdr, WIMStruct *wim,
        }
 }
 
+/*
+ * Convert the short WIM resource header @reshdr to a stand-alone WIM resource
+ * descriptor @rdesc, then set @blob to consist of that entire resource.  This
+ * should only be used for non-solid resources!
+ */
+void
+wim_reshdr_to_desc_and_blob(const struct wim_reshdr *reshdr, WIMStruct *wim,
+                           struct wim_resource_descriptor *rdesc,
+                           struct blob_descriptor *blob)
+{
+       wim_reshdr_to_desc(reshdr, wim, rdesc);
+       blob->size = rdesc->uncompressed_size;
+       blob_set_is_located_in_wim_resource(blob, rdesc, 0);
+}
+
 /* Import a WIM resource header from the on-disk format.  */
 void
 get_wim_reshdr(const struct wim_reshdr_disk *disk_reshdr,