+ * The capture implementation must have set params->capture_root_nchars to an
+ * appropriate value. Example for UNIX: if the capture root directory is
+ * "foobar/subdir", then all paths will be provided starting with
+ * "foobar/subdir", so params->capture_root_nchars must be set to
+ * strlen("foobar/subdir") so that the appropriate path can be matched against
+ * the patterns in the exclusion list.
+ *
+ * Returns:
+ * < 0 if excluded
+ * = 0 if not excluded and no error
+ * > 0 (wimlib error code) if error
+ */
+int
+try_exclude(const tchar *full_path, const struct capture_params *params)
+{
+ int ret;
+
+ if (params->config) {
+ const tchar *path = full_path + params->capture_root_nchars;
+ if (match_pattern_list(path, ¶ms->config->exclusion_pats) &&
+ !match_pattern_list(path, ¶ms->config->exclusion_exception_pats))
+ return -1;
+ }
+
+ if (unlikely(params->add_flags & WIMLIB_ADD_FLAG_TEST_FILE_EXCLUSION)) {
+
+ union wimlib_progress_info info;
+ tchar *cookie;
+
+ info.test_file_exclusion.path = full_path;
+ info.test_file_exclusion.will_exclude = false;
+
+ cookie = progress_get_win32_path(full_path);
+
+ ret = call_progress(params->progfunc, WIMLIB_PROGRESS_MSG_TEST_FILE_EXCLUSION,
+ &info, params->progctx);
+
+ progress_put_win32_path(cookie);
+
+ if (ret)
+ return ret;
+ if (info.test_file_exclusion.will_exclude)
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ * Determine whether a directory entry of the specified name should be ignored.
+ * This is a lower level function which runs prior to try_exclude(). It handles
+ * the standard '.' and '..' entries, which show up in directory listings but
+ * should not be archived. It also checks for odd filenames that usually should
+ * not exist but could cause problems if archiving them were to be attempted.