]> wimlib.net Git - wimlib/blob - include/wimlib/wim.h
Allow configurable case sensitivity
[wimlib] / include / wimlib / wim.h
1 #ifndef _WIMLIB_WIM_H
2 #define _WIMLIB_WIM_H
3
4 #include "wimlib.h"
5 #include "wimlib/header.h"
6 #include "wimlib/types.h"
7 #include "wimlib/file_io.h"
8 #include "wimlib/list.h"
9
10 struct wim_info;
11 struct wim_lookup_table;
12 struct wim_image_metadata;
13
14 /* The opaque structure exposed to the wimlib API. */
15 struct WIMStruct {
16
17         /* File descriptor for the WIM file, opened for reading.  in_fd.fd is -1
18          * if the WIM file has not been opened or there is no associated file
19          * backing it yet. */
20         struct filedes in_fd;
21
22         /* File descriptor, opened either for writing only or for
23          * reading+writing, for the WIM file (if any) currently being written.
24          * */
25         struct filedes out_fd;
26
27         /* The name of the WIM file (if any) that has been opened. */
28         tchar *filename;
29
30         /* The lookup table for the WIM file. */
31         struct wim_lookup_table *lookup_table;
32
33         /* Information retrieved from the XML data, arranged in an orderly
34          * manner. */
35         struct wim_info *wim_info;
36
37         /* Array of the image metadata, one for each image in the WIM. */
38         struct wim_image_metadata **image_metadata;
39
40         /* The header of the WIM file. */
41         struct wim_header hdr;
42
43         /* Temporary field */
44         void *private;
45
46         struct wimlib_decompressor *decompressor;
47         u8 decompressor_ctype;
48         u32 decompressor_max_block_size;
49
50         struct list_head subwims;
51
52         struct list_head subwim_node;
53
54         /* The currently selected image, indexed starting at 1.  If not 0,
55          * subtract 1 from this to get the index of the current image in the
56          * image_metadata array. */
57         int current_image;
58
59         /* Have any images been deleted? */
60         u8 deletion_occurred : 1;
61
62         /* Do we know that all the stream reference counts in the WIM are
63          * correct?  If so, this is set to 1 and deletions are safe; otherwise
64          * this is set to 0 and deletions are not safe until reference counts
65          * are recalculated.  (This is due to a bug in M$'s software that
66          * generates WIMs with invalid reference counts.)  */
67         u8 refcnts_ok : 1;
68
69         u8 wim_locked : 1;
70
71         u8 guid_set_explicitly : 1;
72
73         /* One of WIMLIB_COMPRESSION_TYPE_*, cached from the header flags. */
74         u8 compression_type;
75
76         /* Overridden compression type for wimlib_overwrite() or wimlib_write().
77          * Can be changed by wimlib_set_output_compression_type(); otherwise is
78          * the same as compression_type.  */
79         u8 out_compression_type;
80
81         /* Compression type for writing packed streams; can be set with
82          * wimlib_set_output_pack_compression_type().  */
83         u8 out_pack_compression_type;
84
85         /* Uncompressed size of compressed chunks in this WIM (cached from
86          * header).  */
87         u32 chunk_size;
88
89         /* Overridden chunk size for wimlib_overwrite() or wimlib_write().  Can
90          * be changed by wimlib_set_output_chunk_size(); otherwise is the same
91          * as chunk_size.  */
92         u32 out_chunk_size;
93
94         /* Chunk size for writing packed streams; can be set with
95          * wimlib_set_output_pack_chunk_size().  */
96         u32 out_pack_chunk_size;
97 };
98
99 static inline bool wim_is_pipable(const WIMStruct *wim)
100 {
101         return (wim->hdr.magic == PWM_MAGIC);
102 }
103
104 static inline bool wim_has_integrity_table(const WIMStruct *wim)
105 {
106         return (wim->hdr.integrity_table_reshdr.offset_in_wim != 0);
107 }
108
109 static inline bool wim_has_metadata(const WIMStruct *wim)
110 {
111         return (wim->image_metadata != NULL || wim->hdr.image_count == 0);
112 }
113
114 extern int
115 wim_recalculate_refcnts(WIMStruct *wim);
116
117 extern int
118 set_wim_hdr_cflags(int ctype, struct wim_header *hdr);
119
120 extern int
121 init_wim_header(struct wim_header *hdr, int ctype, u32 chunk_size);
122
123 extern int
124 read_wim_header(WIMStruct *wim, struct wim_header *hdr);
125
126 extern int
127 write_wim_header(const struct wim_header *hdr, struct filedes *out_fd);
128
129 extern int
130 write_wim_header_at_offset(const struct wim_header *hdr, struct filedes *out_fd,
131                            off_t offset);
132
133 extern int
134 write_wim_header_flags(u32 hdr_flags, struct filedes *out_fd);
135
136 extern int
137 select_wim_image(WIMStruct *wim, int image);
138
139 extern int
140 for_image(WIMStruct *wim, int image, int (*visitor)(WIMStruct *));
141
142 extern int
143 wim_checksum_unhashed_streams(WIMStruct *wim);
144
145 extern int
146 reopen_wim(WIMStruct *wim);
147
148 /* Internal open flags (pass to open_wim_as_WIMStruct(), not wimlib_open_wim())
149  */
150 #define WIMLIB_OPEN_FLAG_FROM_PIPE      0x80000000
151 #define WIMLIB_OPEN_MASK_PUBLIC         0x7fffffff
152
153 extern int
154 open_wim_as_WIMStruct(const void *wim_filename_or_fd, int open_flags,
155                       WIMStruct **wim_ret,
156                       wimlib_progress_func_t progress_func);
157
158 extern int
159 close_wim(WIMStruct *wim);
160
161 extern int
162 can_modify_wim(WIMStruct *wim);
163
164 extern int
165 can_delete_from_wim(WIMStruct *wim);
166
167 #endif /* _WIMLIB_WIM_H */