1 #ifndef _WIMLIB_RESOURCE_H
2 #define _WIMLIB_RESOURCE_H
4 #include "wimlib/types.h"
5 #include "wimlib/callback.h"
7 struct wim_lookup_table_entry;
8 struct wim_image_metadata;
10 /* Metadata for a resource in a WIM file. */
11 struct resource_entry {
12 /* Size, in bytes, of the resource in the WIM file. */
15 /* Bitwise or of one or more of the WIM_RESHDR_FLAG_* flags. */
18 /* Offset, in bytes, of the resource in the WIM file. */
21 /* Uncompressed size of the resource in the WIM file. Is the same as
22 * @size if the resource is uncompressed. */
26 struct resource_entry_disk {
33 /* Flags for the `flags' field of the struct resource_entry structure. */
35 /* I haven't seen this flag used in any of the WIMs I have examined. I assume
36 * it means that there are no references to the stream, so the space is free.
37 * However, even after deleting files from a WIM mounted with `imagex.exe
38 * /mountrw', I could not see this flag being used. Either way, we don't
39 * actually use this flag for anything. */
40 #define WIM_RESHDR_FLAG_FREE 0x01
42 /* Indicates that the stream is a metadata resource for a WIM image. */
43 #define WIM_RESHDR_FLAG_METADATA 0x02
45 /* Indicates that the stream is compressed. */
46 #define WIM_RESHDR_FLAG_COMPRESSED 0x04
48 /* I haven't seen this flag used in any of the WIMs I have examined. Perhaps it
49 * means that a stream could possibly be split among multiple split WIM parts.
50 * However, `imagex.exe /split' does not seem to create any WIMs like this.
51 * Either way, we don't actually use this flag for anything. */
52 #define WIM_RESHDR_FLAG_SPANNED 0x08
54 /* Nonzero if a struct resource_entry indicates a compressed resource. */
56 resource_is_compressed(const struct resource_entry *entry)
58 return (entry->flags & WIM_RESHDR_FLAG_COMPRESSED);
62 # define copy_resource_entry(dst, src) memcpy(dst, src, sizeof(struct resource_entry))
63 # define zero_resource_entry(entry) memset(entry, 0, sizeof(struct resource_entry))
66 copy_resource_entry(struct resource_entry *dst,
67 const struct resource_entry *src)
69 BUILD_BUG_ON(sizeof(struct resource_entry) != 24);
70 ((u64*)dst)[0] = ((u64*)src)[0];
71 ((u64*)dst)[1] = ((u64*)src)[1];
72 ((u64*)dst)[2] = ((u64*)src)[2];
76 zero_resource_entry(struct resource_entry *entry)
78 BUILD_BUG_ON(sizeof(struct resource_entry) != 24);
85 #define WIMLIB_RESOURCE_FLAG_RAW 0x1
86 #define WIMLIB_RESOURCE_FLAG_RECOMPRESS 0x2
89 read_resource_prefix(const struct wim_lookup_table_entry *lte,
90 u64 size, consume_data_callback_t cb, void *ctx_or_buf,
94 get_resource_entry(const struct resource_entry_disk *disk_entry,
95 struct resource_entry *entry);
98 put_resource_entry(const struct resource_entry *entry,
99 struct resource_entry_disk *disk_entry);
102 read_partial_wim_resource_into_buf(const struct wim_lookup_table_entry *lte,
103 size_t size, u64 offset, void *buf);
105 read_full_resource_into_buf(const struct wim_lookup_table_entry *lte, void *buf);
108 write_wim_resource(struct wim_lookup_table_entry *lte, int out_fd,
109 int out_ctype, struct resource_entry *out_res_entry,
113 extract_wim_resource(const struct wim_lookup_table_entry *lte,
115 consume_data_callback_t extract_chunk,
116 void *extract_chunk_arg);
119 extract_wim_resource_to_fd(const struct wim_lookup_table_entry *lte,
123 sha1_resource(struct wim_lookup_table_entry *lte);
126 copy_resource(struct wim_lookup_table_entry *lte, void *w);
129 read_metadata_resource(WIMStruct *w,
130 struct wim_image_metadata *image_metadata);
133 write_metadata_resource(WIMStruct *w);
135 #endif /* _WIMLIB_RESOURCE_H */