+/* Extracts a file, directory, or symbolic link from the WIM archive. */
+static int
+apply_dentry_normal(struct wim_dentry *dentry, void *arg)
+{
+#ifdef __WIN32__
+ return do_apply_op(dentry, arg, win32_do_apply_dentry);
+#else
+ return do_apply_op(dentry, arg, unix_do_apply_dentry);
+#endif
+}
+
+
+/* Apply timestamps to an extracted file or directory */
+static int
+apply_dentry_timestamps_normal(struct wim_dentry *dentry, void *arg)
+{
+#ifdef __WIN32__
+ return do_apply_op(dentry, arg, win32_do_apply_dentry_timestamps);
+#else
+ return do_apply_op(dentry, arg, unix_do_apply_dentry_timestamps);
+#endif
+}
+
+static bool
+dentry_is_dot_or_dotdot(const struct wim_dentry *dentry)
+{
+ const utf16lechar *file_name = dentry->file_name;
+ return file_name != NULL &&
+ file_name[0] == cpu_to_le16('.') &&
+ (file_name[1] == cpu_to_le16('\0') ||
+ (file_name[1] == cpu_to_le16('.') &&
+ file_name[2] == cpu_to_le16('\0')));
+}
+
+/* Extract a dentry if it hasn't already been extracted and either
+ * WIMLIB_EXTRACT_FLAG_NO_STREAMS is not specified, or the dentry is a directory
+ * and/or has no unnamed stream. */
+static int
+maybe_apply_dentry(struct wim_dentry *dentry, void *arg)
+{
+ struct apply_args *args = arg;
+ int ret;
+
+ if (!dentry->needs_extraction)
+ return 0;
+
+ if (args->extract_flags & WIMLIB_EXTRACT_FLAG_NO_STREAMS &&
+ !dentry_is_directory(dentry) &&
+ inode_unnamed_lte_resolved(dentry->d_inode) != NULL)
+ return 0;
+
+ if ((args->extract_flags & WIMLIB_EXTRACT_FLAG_VERBOSE) &&
+ args->progress_func) {
+ ret = calculate_dentry_full_path(dentry);
+ if (ret)
+ return ret;
+ args->progress.extract.cur_path = dentry->_full_path;
+ args->progress_func(WIMLIB_PROGRESS_MSG_EXTRACT_DENTRY,
+ &args->progress);
+ }
+ ret = args->apply_dentry(dentry, args);
+ if (ret == 0)
+ dentry->needs_extraction = 0;
+ return ret;
+}
+
+static void
+calculate_bytes_to_extract(struct list_head *stream_list,
+ int extract_flags,
+ union wimlib_progress_info *progress)
+{
+ struct wim_lookup_table_entry *lte;
+ u64 total_bytes = 0;
+ u64 num_streams = 0;
+
+ /* For each stream to be extracted... */
+ list_for_each_entry(lte, stream_list, extraction_list) {
+ if (extract_flags &
+ (WIMLIB_EXTRACT_FLAG_SYMLINK | WIMLIB_EXTRACT_FLAG_HARDLINK))
+ {
+ /* In the symlink or hard link extraction mode, each
+ * stream will be extracted one time regardless of how
+ * many dentries share the stream. */
+ wimlib_assert(!(extract_flags & WIMLIB_EXTRACT_FLAG_NTFS));
+ if (!lte->extracted_file) {
+ num_streams++;
+ total_bytes += wim_resource_size(lte);
+ }
+ } else {
+ num_streams += lte->out_refcnt;
+ total_bytes += lte->out_refcnt * wim_resource_size(lte);