]> wimlib.net Git - wimlib/blob - include/wimlib/apply.h
Add WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN
[wimlib] / include / wimlib / apply.h
1 #ifndef _WIMLIB_APPLY_H
2 #define _WIMLIB_APPLY_H
3
4 #include "wimlib/types.h"
5 #include "wimlib/list.h"
6 #include "wimlib.h"
7
8 struct wim_lookup_table_entry;
9 struct wimlib_unix_data;
10 struct wim_dentry;
11 struct apply_ctx;
12
13 /*
14  * struct apply_operations -  Callback functions for a specific extraction
15  * mode/backend.  These are lower-level functions that are called by the generic
16  * code in extract.c.
17  *
18  * Unless otherwise specified, the callbacks in this structure are expected to
19  * return 0 on success or a WIMLIB_ERR_* value on failure as well as set errno.
20  * When possible, error messages should NOT be printed as they are handled by
21  * the generic code.
22  *
23  * Many callbacks are optional, but to extract the most data from the WIM
24  * format, as many as possible should be provided, and the corresponding
25  * features should be marked as supported in start_extract().
26  */
27 struct apply_operations {
28
29         /* OPTIONAL:  Name of this extraction mode.  */
30         const tchar *name;
31
32         /* REQUIRED:  Fill in ctx->supported_features with nonzero values for
33          * features supported by the extraction mode and volume.  This callback
34          * can also be used to do any setup needed to access the volume.  */
35         int (*start_extract)
36                 (const tchar *path, struct apply_ctx *ctx);
37
38         /* OPTIONAL:  If root_directory_is_special is set:  provide this
39          * callback to determine whether the path corresponds to the root of the
40          * target volume (%true) or not (%false).  */
41         bool (*target_is_root)
42                 (const tchar *target);
43
44         /* REQUIRED:  Create a file.  */
45         int (*create_file)
46                 (const tchar *path, struct apply_ctx *ctx);
47
48         /* REQUIRED:  Create a directory.  */
49         int (*create_directory)
50                 (const tchar *path, struct apply_ctx *ctx);
51
52         /* OPTIONAL:  Create a hard link.  In start_extract(), set
53          * ctx->supported_features.hard_links if supported.  */
54         int (*create_hardlink)
55                 (const tchar *oldpath, const tchar *newpath,
56                  struct apply_ctx *ctx);
57
58         /* OPTIONAL:  Create a symbolic link.  In start_extract(), set
59          * ctx->supported_features.symlink_reparse_points if supported.  */
60         int (*create_symlink)
61                 (const tchar *oldpath, const tchar *newpath,
62                  struct apply_ctx *ctx);
63
64         /* REQUIRED:  Extract unnamed data stream.  */
65         int (*extract_unnamed_stream)
66                 (const tchar *path, struct wim_lookup_table_entry *lte,
67                  struct apply_ctx *ctx);
68
69         /* OPTIONAL:  Extracted named data stream.  In start_extract(), set
70          * ctx->supported_features.alternate_data_streams if supported.  */
71         int (*extract_named_stream)
72                 (const tchar *path, const utf16lechar *stream_name,
73                  size_t stream_name_nchars, struct wim_lookup_table_entry *lte,
74                  struct apply_ctx *ctx);
75
76         /* OPTIONAL:  Extracted encrypted stream.  In start_extract(), set
77          * ctx->supported_features.encrypted_files if supported.  */
78         int (*extract_encrypted_stream)
79                 (const tchar *path, struct wim_lookup_table_entry *lte,
80                  struct apply_ctx *ctx);
81
82         /* OPTIONAL:  Set file attributes.  Calling code calls this if non-NULL.
83          */
84         int (*set_file_attributes)
85                 (const tchar *path, u32 attributes, struct apply_ctx *ctx);
86
87         /* OPTIONAL:  Set reparse data.  In start_extract(), set
88          * ctx->supported_features.reparse_data if supported.  */
89         int (*set_reparse_data)
90                 (const tchar *path, const u8 *rpbuf, u16 rpbuflen,
91                  struct apply_ctx *ctx);
92
93         /* OPTIONAL:  Set short (DOS) filename.  In start_extract(), set
94          * ctx->supported_features.short_name if supported.  */
95         int (*set_short_name)
96                 (const tchar *path, const utf16lechar *short_name,
97                  size_t short_name_nchars, struct apply_ctx *ctx);
98
99         /* OPTIONAL:  Set Windows NT security descriptor.  In start_extract(),
100          * set ctx->supported_features.security_descriptors if supported.  */
101         int (*set_security_descriptor)
102                 (const tchar *path, const u8 *desc, size_t desc_size,
103                  struct apply_ctx *ctx);
104
105         /* OPTIONAL:  Set wimlib-specific UNIX data.  In start_extract(), set
106          * ctx->supported_features.unix_data if supported.  */
107         int (*set_unix_data)
108                 (const tchar *path, const struct wimlib_unix_data *data,
109                  struct apply_ctx *ctx);
110
111         /* OPTIONAL:  Set timestamps.  Calling code calls this if non-NULL.  */
112         int (*set_timestamps)
113                 (const tchar *path, u64 creation_time, u64 last_write_time,
114                  u64 last_access_time, struct apply_ctx *ctx);
115
116         /* OPTIONAL:  Called after the extraction operation has succeeded.  */
117         int (*finish_extract)
118                 (struct apply_ctx *ctx);
119
120         /* OPTIONAL:  Called after the extraction operation has failed.  */
121         int (*abort_extract)
122                 (struct apply_ctx *ctx);
123
124         /* REQUIRED:  Path separator character to use when building paths.  */
125         tchar path_separator;
126
127         /* REQUIRED:  Maximum path length, in tchars, including the
128          * null-terminator.  */
129         unsigned path_max;
130
131         /* OPTIONAL:  String to prefix every path with.  */
132         const tchar *path_prefix;
133
134         /* OPTIONAL:  Length of path_prefix in tchars.  */
135         unsigned path_prefix_nchars;
136
137         /* OPTIONAL:  Set to 1 if paths must be prefixed by the name of the
138          * extraction target (i.e. if it's interpreted as a directory).  */
139         unsigned requires_target_in_paths : 1;
140
141         /* OPTIONAL:  Like above, but operations require real (absolute) path.
142          * */
143         unsigned requires_realtarget_in_paths : 1;
144
145         /* OPTIONAL:  Set to 1 if realpath() can be used to get the real
146          * (absolute) path of a file on the target volume before it's been
147          * created.  */
148         unsigned realpath_works_on_nonexisting_files : 1;
149
150         /* OPTIONAL:  Set to 1 if this extraction mode supports case sensitive
151          * filenames.  */
152         unsigned supports_case_sensitive_filenames : 1;
153
154         /* OPTIONAL:  Set to 1 if the root directory of the volume (see
155          * target_is_root() callback) should not be explicitly extracted.  */
156         unsigned root_directory_is_special : 1;
157 };
158
159 struct wim_features {
160         unsigned long archive_files;
161         unsigned long hidden_files;
162         unsigned long system_files;
163         unsigned long compressed_files;
164         unsigned long encrypted_files;
165         unsigned long not_context_indexed_files;
166         unsigned long sparse_files;
167         unsigned long named_data_streams;
168         unsigned long hard_links;
169         unsigned long reparse_points;
170         unsigned long symlink_reparse_points;
171         unsigned long other_reparse_points;
172         unsigned long security_descriptors;
173         unsigned long short_names;
174         unsigned long unix_data;
175 };
176
177 /* Context for an apply (extract) operation.  */
178 struct apply_ctx {
179         WIMStruct *wim;
180         int extract_flags;
181         const tchar *target;
182         size_t target_nchars;
183         wimlib_progress_func_t progress_func;
184         union wimlib_progress_info progress;
185         struct wim_dentry *extract_root;
186         const struct apply_operations *ops;
187         struct wim_features supported_features;
188         struct list_head stream_list;
189         tchar *realtarget;
190         size_t realtarget_nchars;
191         unsigned long invalid_sequence;
192         u64 num_streams_remaining;
193         bool root_dentry_is_special;
194         uint64_t next_progress;
195         intptr_t private[8];
196 };
197
198 #ifdef __WIN32__
199   extern const struct apply_operations win32_apply_ops;
200 #else
201   extern const struct apply_operations unix_apply_ops;
202 #endif
203
204 #ifdef WITH_NTFS_3G
205   extern const struct apply_operations ntfs_3g_apply_ops;
206 #endif
207
208 #endif /* _WIMLIB_APPLY_H */