-static int sort_image_metadata_by_position(const void *p1, const void *p2)
-{
- const struct image_metadata *imd1 = p1;
- const struct image_metadata *imd2 = p2;
- u64 offset1 = imd1->metadata_lte->resource_entry.offset;
- u64 offset2 = imd2->metadata_lte->resource_entry.offset;
- if (offset1 < offset2)
- return -1;
- else if (offset1 > offset2)
- return 1;
- else
- return 0;
-}
-
-/*
- * If @lte points to a metadata resource, append it to the list of metadata
- * resources in the WIMStruct. Otherwise, do nothing.
- */
-static int append_metadata_resource_entry(struct lookup_table_entry *lte,
- void *wim_p)
-{
- WIMStruct *w = wim_p;
- int ret = 0;
-
- if (lte->resource_entry.flags & WIM_RESHDR_FLAG_METADATA) {
- if (w->current_image == w->hdr.image_count) {
- ERROR("The WIM header says there are %u images in the WIM,\n"
- " but we found more metadata resources than this",
- w->hdr.image_count);
- ret = WIMLIB_ERR_IMAGE_COUNT;
- } else {
- DEBUG("Found metadata resource for image %u at "
- "offset %"PRIu64".",
- w->current_image + 1,
- lte->resource_entry.offset);
- w->image_metadata[
- w->current_image++].metadata_lte = lte;
- }
- }
- return ret;
-}
-
-/* Returns the compression type given in the flags of a WIM header. */
-int wim_hdr_flags_compression_type(int wim_hdr_flags)
-{
- if (wim_hdr_flags & WIM_HDR_FLAG_COMPRESSION) {
- if (wim_hdr_flags & WIM_HDR_FLAG_COMPRESS_LZX)
- return WIMLIB_COMPRESSION_TYPE_LZX;
- else if (wim_hdr_flags & WIM_HDR_FLAG_COMPRESS_XPRESS)
- return WIMLIB_COMPRESSION_TYPE_XPRESS;
- else
- return WIMLIB_COMPRESSION_TYPE_INVALID;
- } else {
- return WIMLIB_COMPRESSION_TYPE_NONE;
- }
-}
-
-/*
- * Creates a WIMStruct for a new WIM file.
- */
-WIMLIBAPI int wimlib_create_new_wim(int ctype, WIMStruct **w_ret)