]> wimlib.net Git - wimlib/blob - include/wimlib/apply.h
Use completed_streams and total_streams in extract progress
[wimlib] / include / wimlib / apply.h
1 #ifndef _WIMLIB_APPLY_H
2 #define _WIMLIB_APPLY_H
3
4 #include "wimlib/file_io.h"
5 #include "wimlib/list.h"
6 #include "wimlib/progress.h"
7 #include "wimlib/types.h"
8 #include "wimlib.h"
9
10 /* These can be treated as counts (for required_features) or booleans (for
11  * supported_features).  */
12 struct wim_features {
13         unsigned long archive_files;
14         unsigned long hidden_files;
15         unsigned long system_files;
16         unsigned long compressed_files;
17         unsigned long encrypted_files;
18         unsigned long encrypted_directories;
19         unsigned long not_context_indexed_files;
20         unsigned long sparse_files;
21         unsigned long named_data_streams;
22         unsigned long hard_links;
23         unsigned long reparse_points;
24         unsigned long symlink_reparse_points;
25         unsigned long other_reparse_points;
26         unsigned long security_descriptors;
27         unsigned long short_names;
28         unsigned long unix_data;
29         unsigned long timestamps;
30         unsigned long case_sensitive_filenames;
31 };
32
33 struct wim_lookup_table_entry;
34 struct read_stream_list_callbacks;
35
36 struct apply_ctx {
37         /* The WIMStruct from which files are being extracted from the currently
38          * selected image.  */
39         WIMStruct *wim;
40
41         /* The target of the extraction, usually the path to a directory.  */
42         const tchar *target;
43
44         /* Length of @target in tchars.  */
45         size_t target_nchars;
46
47         /* Extraction flags (WIMLIB_EXTRACT_FLAG_*)  */
48         int extract_flags;
49
50         /* User-provided progress function, or NULL if not specified.  */
51         wimlib_progress_func_t progfunc;
52         void *progctx;
53
54         /* Progress data buffer, with progress.extract initialized.  */
55         union wimlib_progress_info progress;
56
57         /* Features required to extract the files (with counts)  */
58         struct wim_features required_features;
59
60         /* Features supported by the extraction mode (with booleans)  */
61         struct wim_features supported_features;
62
63         /* The members below should not be used outside of extract.c  */
64         u64 next_progress;
65         unsigned long invalid_sequence;
66         unsigned long num_streams_remaining;
67         struct list_head stream_list;
68         const struct read_stream_list_callbacks *saved_cbs;
69         struct wim_lookup_table_entry *cur_stream;
70         u64 cur_stream_offset;
71         struct filedes tmpfile_fd;
72         tchar *tmpfile_name;
73 };
74
75 /* Maximum number of UNIX file descriptors, NTFS attributes, or Windows file
76  * handles that can be opened simultaneously to extract a single-instance
77  * stream to multiple destinations.  */
78 #define MAX_OPEN_STREAMS 512
79
80 static inline int
81 extract_progress(struct apply_ctx *ctx, enum wimlib_progress_msg msg)
82 {
83         return call_progress(ctx->progfunc, msg, &ctx->progress, ctx->progctx);
84 }
85
86 /* Returns any of the aliases of an inode that are being extracted.  */
87 #define inode_first_extraction_dentry(inode)            \
88         list_first_entry(&(inode)->i_extraction_aliases,        \
89                          struct wim_dentry, d_extraction_alias_node)
90
91 extern int
92 extract_stream_list(struct apply_ctx *ctx,
93                     const struct read_stream_list_callbacks *cbs);
94
95 struct apply_operations {
96         const char *name;
97         int (*get_supported_features)(const tchar *target,
98                                       struct wim_features *supported_features);
99
100         int (*extract)(struct list_head *dentry_list, struct apply_ctx *ctx);
101
102         size_t context_size;
103         bool single_tree_only;
104 };
105
106 #ifdef __WIN32__
107   extern const struct apply_operations win32_apply_ops;
108 #else
109   extern const struct apply_operations unix_apply_ops;
110 #endif
111
112 #ifdef WITH_NTFS_3G
113   extern const struct apply_operations ntfs_3g_apply_ops;
114 #endif
115
116 #endif /* _WIMLIB_APPLY_H */