1 #ifndef _WIMLIB_APPLY_H
2 #define _WIMLIB_APPLY_H
4 #include "wimlib/types.h"
5 #include "wimlib/list.h"
8 struct wim_lookup_table_entry;
9 struct wimlib_unix_data;
14 * struct apply_operations - Callback functions for a specific extraction
15 * mode/backend. These are lower-level functions that are called by the generic
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
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().
27 struct apply_operations {
29 /* OPTIONAL: Name of this extraction mode. */
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. */
36 (const tchar *path, struct apply_ctx *ctx);
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);
44 /* REQUIRED: Create a file. */
46 (const tchar *path, struct apply_ctx *ctx);
48 /* REQUIRED: Create a directory. */
49 int (*create_directory)
50 (const tchar *path, struct apply_ctx *ctx);
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);
58 /* OPTIONAL: Create a symbolic link. In start_extract(), set
59 * ctx->supported_features.symlink_reparse_points if supported. */
61 (const tchar *oldpath, const tchar *newpath,
62 struct apply_ctx *ctx);
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);
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);
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);
82 /* OPTIONAL: Set file attributes. Calling code calls this if non-NULL.
84 int (*set_file_attributes)
85 (const tchar *path, u32 attributes, struct apply_ctx *ctx);
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);
93 /* OPTIONAL: Set short (DOS) filename. In start_extract(), set
94 * ctx->supported_features.short_name if supported. */
96 (const tchar *path, const utf16lechar *short_name,
97 size_t short_name_nchars, struct apply_ctx *ctx);
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, bool strict);
105 /* OPTIONAL: Set wimlib-specific UNIX data. In start_extract(), set
106 * ctx->supported_features.unix_data if supported. */
108 (const tchar *path, const struct wimlib_unix_data *data,
109 struct apply_ctx *ctx);
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);
116 /* OPTIONAL: Called after the extraction operation has succeeded. */
117 int (*finish_extract)
118 (struct apply_ctx *ctx);
120 /* OPTIONAL: Called after the extraction operation has failed. */
122 (struct apply_ctx *ctx);
124 /* REQUIRED: Path separator character to use when building paths. */
125 tchar path_separator;
127 /* REQUIRED: Maximum path length, in tchars, including the
128 * null-terminator. */
131 /* OPTIONAL: String to prefix every path with. */
132 const tchar *path_prefix;
134 /* OPTIONAL: Length of path_prefix in tchars. */
135 unsigned path_prefix_nchars;
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;
141 /* OPTIONAL: Like above, but operations require real (absolute) path.
143 unsigned requires_realtarget_in_paths : 1;
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
148 unsigned realpath_works_on_nonexisting_files : 1;
150 /* OPTIONAL: Set to 1 if this extraction mode supports case sensitive
152 unsigned supports_case_sensitive_filenames : 1;
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;
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;
177 /* Context for an apply (extract) operation. */
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;
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;
199 extern const struct apply_operations win32_apply_ops;
201 extern const struct apply_operations unix_apply_ops;
205 extern const struct apply_operations ntfs_3g_apply_ops;
208 #endif /* _WIMLIB_APPLY_H */