X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fresource.c;h=9afa25ffc626842a55883d566a3474a1b83318d1;hb=ce50e9190bdb770640a53a1a8d612229be65d8e7;hp=74c9bb8b9a9570aa52110139e73cc9a0907982bb;hpb=c48e2f84645abe34faec4994605d7a7b3b451672;p=wimlib diff --git a/src/resource.c b/src/resource.c index 74c9bb8b..9afa25ff 100644 --- a/src/resource.c +++ b/src/resource.c @@ -103,7 +103,7 @@ struct data_range { * * WIMLIB_ERR_SUCCESS (0) * WIMLIB_ERR_READ (errno set) - * WIMLIB_ERR_UNEXPECTED_END_OF_FILE (errno set to 0) + * WIMLIB_ERR_UNEXPECTED_END_OF_FILE (errno set to EINVAL) * WIMLIB_ERR_NOMEM (errno set to ENOMEM) * WIMLIB_ERR_DECOMPRESSION (errno set to EINVAL) * WIMLIB_ERR_INVALID_CHUNK_SIZE (errno set to EINVAL) @@ -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,