]> wimlib.net Git - wimlib/blob - include/wimlib/wim.h
Merge branch with pipable WIM support
[wimlib] / include / wimlib / wim.h
1 #ifndef _WIMLIB_WIM_H
2 #define _WIMLIB_WIM_H
3
4 #include "wimlib/header.h"
5 #include "wimlib/types.h"
6 #include "wimlib/file_io.h"
7
8 struct wim_info;
9 struct wim_lookup_table;
10 struct wim_image_metadata;
11
12 /* The opaque structure exposed to the wimlib API. */
13 struct WIMStruct {
14
15         /* File descriptor for the WIM file, opened for reading.  in_fd.fd is -1
16          * if the WIM file has not been opened or there is no associated file
17          * backing it yet. */
18         struct filedes in_fd;
19
20         /* File descriptor, opened either for writing only or for
21          * reading+writing, for the WIM file (if any) currently being written.
22          * */
23         struct filedes out_fd;
24
25         /* The name of the WIM file (if any) that has been opened. */
26         tchar *filename;
27
28         /* The lookup table for the WIM file. */
29         struct wim_lookup_table *lookup_table;
30
31         /* Information retrieved from the XML data, arranged in an orderly
32          * manner. */
33         struct wim_info *wim_info;
34
35         /* Array of the image metadata, one for each image in the WIM. */
36         struct wim_image_metadata **image_metadata;
37
38         /* The header of the WIM file. */
39         struct wim_header hdr;
40
41         /* Temporary field */
42         void *private;
43
44         /* The currently selected image, indexed starting at 1.  If not 0,
45          * subtract 1 from this to get the index of the current image in the
46          * image_metadata array. */
47         int current_image;
48
49         /* Have any images been deleted? */
50         u8 deletion_occurred : 1;
51
52         /* Do we know that all the stream reference counts in the WIM are
53          * correct?  If so, this is set to 1 and deletions are safe; otherwise
54          * this is set to 0 and deletions are not safe until reference counts
55          * are recalculated.  (This is due to a bug in M$'s software that
56          * generates WIMs with invalid reference counts.)  */
57         u8 refcnts_ok : 1;
58
59         u8 wim_locked : 1;
60
61         /* One of WIMLIB_COMPRESSION_TYPE_*, cached from the header flags. */
62         u8 compression_type : 2;
63 };
64
65 static inline bool wim_is_pipable(const WIMStruct *wim)
66 {
67         return (wim->hdr.magic == PWM_MAGIC);
68 }
69
70 static inline bool wim_has_integrity_table(const WIMStruct *wim)
71 {
72         return (wim->hdr.integrity.offset != 0);
73 }
74
75 extern void
76 wim_recalculate_refcnts(WIMStruct *wim);
77
78 extern int
79 init_wim_header(struct wim_header *hdr, int ctype);
80
81 extern int
82 read_wim_header(const tchar *filename, struct filedes *in_fd,
83                 struct wim_header *hdr);
84
85 extern int
86 write_wim_header(const struct wim_header *hdr, struct filedes *out_fd);
87
88 extern int
89 write_wim_header_at_offset(const struct wim_header *hdr, struct filedes *out_fd,
90                            off_t offset);
91
92 extern int
93 write_wim_header_flags(u32 hdr_flags, struct filedes *out_fd);
94
95 extern int
96 rename_wim_path(WIMStruct *wim, const tchar *from, const tchar *to);
97
98 extern int
99 select_wim_image(WIMStruct *wim, int image);
100
101 extern int
102 for_image(WIMStruct *wim, int image, int (*visitor)(WIMStruct *));
103
104 extern int
105 wim_checksum_unhashed_streams(WIMStruct *wim);
106
107 extern int
108 reopen_wim(WIMStruct *wim);
109
110 /* Internal open flags (pass to open_wim_as_WIMStruct(), not wimlib_open_wim())
111  */
112 #define WIMLIB_OPEN_FLAG_FROM_PIPE      0x80000000
113 #define WIMLIB_OPEN_MASK_PUBLIC         0x7fffffff
114
115 extern int
116 open_wim_as_WIMStruct(const void *wim_filename_or_fd, int open_flags,
117                       WIMStruct **wim_ret,
118                       wimlib_progress_func_t progress_func);
119
120 extern int
121 close_wim(WIMStruct *wim);
122
123 extern int
124 can_modify_wim(WIMStruct *wim);
125
126 extern int
127 can_delete_from_wim(WIMStruct *wim);
128
129 #endif /* _WIMLIB_WIM_H */