4 #include "wimlib/header.h"
5 #include "wimlib/types.h"
6 #include "wimlib/file_io.h"
7 #include "wimlib/list.h"
10 struct wim_lookup_table;
11 struct wim_image_metadata;
13 /* The opaque structure exposed to the wimlib API. */
16 /* File descriptor for the WIM file, opened for reading. in_fd.fd is -1
17 * if the WIM file has not been opened or there is no associated file
21 /* File descriptor, opened either for writing only or for
22 * reading+writing, for the WIM file (if any) currently being written.
24 struct filedes out_fd;
26 /* The name of the WIM file (if any) that has been opened. */
29 /* The lookup table for the WIM file. */
30 struct wim_lookup_table *lookup_table;
32 /* Information retrieved from the XML data, arranged in an orderly
34 struct wim_info *wim_info;
36 /* Array of the image metadata, one for each image in the WIM. */
37 struct wim_image_metadata **image_metadata;
39 /* The header of the WIM file. */
40 struct wim_header hdr;
45 /* LZX compression context for default thread */
46 struct wimlib_lzx_context *lzx_context;
48 struct list_head subwims;
50 struct list_head subwim_node;
52 /* The currently selected image, indexed starting at 1. If not 0,
53 * subtract 1 from this to get the index of the current image in the
54 * image_metadata array. */
57 /* Have any images been deleted? */
58 u8 deletion_occurred : 1;
60 /* Do we know that all the stream reference counts in the WIM are
61 * correct? If so, this is set to 1 and deletions are safe; otherwise
62 * this is set to 0 and deletions are not safe until reference counts
63 * are recalculated. (This is due to a bug in M$'s software that
64 * generates WIMs with invalid reference counts.) */
69 u8 guid_set_explicitly : 1;
71 /* One of WIMLIB_COMPRESSION_TYPE_*, cached from the header flags. */
72 u8 compression_type : 2;
74 /* Overwritten compression type for wimlib_overwrite() or
75 * wimlib_write(). Can be changed by
76 * wimlib_set_output_compression_type(); otherwise is the same as
77 * compression_type. */
78 u8 out_compression_type : 2;
80 /* Uncompressed size of compressed chunks in this WIM (cached from
84 /* Overridden chunk size for wimlib_overwrite() or wimlib_write(). Can
85 * be changed by wimlib_set_output_chunk_size(); otherwise is the same
90 static inline bool wim_is_pipable(const WIMStruct *wim)
92 return (wim->hdr.magic == PWM_MAGIC);
95 static inline bool wim_has_integrity_table(const WIMStruct *wim)
97 return (wim->hdr.integrity_table_reshdr.offset_in_wim != 0);
100 static inline bool wim_has_metadata(const WIMStruct *wim)
102 return (wim->image_metadata != NULL || wim->hdr.image_count == 0);
106 wim_recalculate_refcnts(WIMStruct *wim);
109 set_wim_hdr_cflags(int ctype, struct wim_header *hdr);
112 init_wim_header(struct wim_header *hdr, int ctype, u32 chunk_size);
115 read_wim_header(WIMStruct *wim, struct wim_header *hdr);
118 write_wim_header(const struct wim_header *hdr, struct filedes *out_fd);
121 write_wim_header_at_offset(const struct wim_header *hdr, struct filedes *out_fd,
125 write_wim_header_flags(u32 hdr_flags, struct filedes *out_fd);
128 rename_wim_path(WIMStruct *wim, const tchar *from, const tchar *to);
131 select_wim_image(WIMStruct *wim, int image);
134 for_image(WIMStruct *wim, int image, int (*visitor)(WIMStruct *));
137 wim_checksum_unhashed_streams(WIMStruct *wim);
140 reopen_wim(WIMStruct *wim);
142 /* Internal open flags (pass to open_wim_as_WIMStruct(), not wimlib_open_wim())
144 #define WIMLIB_OPEN_FLAG_FROM_PIPE 0x80000000
145 #define WIMLIB_OPEN_MASK_PUBLIC 0x7fffffff
148 open_wim_as_WIMStruct(const void *wim_filename_or_fd, int open_flags,
150 wimlib_progress_func_t progress_func);
153 close_wim(WIMStruct *wim);
156 can_modify_wim(WIMStruct *wim);
159 can_delete_from_wim(WIMStruct *wim);
161 #endif /* _WIMLIB_WIM_H */