]> wimlib.net Git - wimlib/blob - include/wimlib/wim.h
a2d664eaf07d54e0f4decaca423fd3f719d1fc88
[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
7 struct wim_info;
8 struct wim_lookup_table;
9 struct wim_image_metadata;
10
11 /* The opaque structure exposed to the wimlib API. */
12 struct WIMStruct {
13
14         /* File descriptor for the WIM file, opened for reading, or -1 if it has
15          * not been opened or there is no associated file backing it yet. */
16         int in_fd;
17
18         /* File descriptor, opened either for writing only or for
19          * reading+writing, for the WIM file (if any) currently being written.
20          * */
21         int out_fd;
22
23         /* The name of the WIM file (if any) that has been opened. */
24         tchar *filename;
25
26         /* The lookup table for the WIM file. */
27         struct wim_lookup_table *lookup_table;
28
29         /* Information retrieved from the XML data, arranged in an orderly
30          * manner. */
31         struct wim_info *wim_info;
32
33         /* Array of the image metadata, one for each image in the WIM. */
34         struct wim_image_metadata **image_metadata;
35
36         /* The header of the WIM file. */
37         struct wim_header hdr;
38
39         /* Temporary field */
40         void *private;
41
42         /* The currently selected image, indexed starting at 1.  If not 0,
43          * subtract 1 from this to get the index of the current image in the
44          * image_metadata array. */
45         int current_image;
46
47         /* Have any images been deleted? */
48         u8 deletion_occurred : 1;
49
50         /* Do we know that all the stream reference counts in the WIM are
51          * correct?  If so, this is set to 1 and deletions are safe; otherwise
52          * this is set to 0 and deletions are not safe until reference counts
53          * are recalculated.  (This is due to a bug in M$'s software that
54          * generates WIMs with invalid reference counts.)  */
55         u8 refcnts_ok : 1;
56
57         u8 wim_locked : 1;
58 };
59
60 extern void
61 wim_recalculate_refcnts(WIMStruct *wim);
62
63 extern int
64 read_header(const tchar *filename, int in_fd, struct wim_header *hdr);
65
66 extern int
67 write_header(const struct wim_header *hdr, int out_fd);
68
69 extern int
70 init_header(struct wim_header *hdr, int ctype);
71
72
73 extern int
74 rename_wim_path(WIMStruct *wim, const tchar *from, const tchar *to);
75
76 extern int
77 select_wim_image(WIMStruct *w, int image);
78
79 extern int
80 for_image(WIMStruct *w, int image, int (*visitor)(WIMStruct *));
81
82 extern int
83 wim_checksum_unhashed_streams(WIMStruct *w);
84
85 extern int
86 reopen_wim(WIMStruct *w);
87
88 extern int
89 close_wim(WIMStruct *w);
90
91 extern int
92 can_modify_wim(WIMStruct *wim);
93
94 extern int
95 can_delete_from_wim(WIMStruct *wim);
96
97 #endif /* _WIMLIB_WIM_H */