fswatch 1.21.0
Loading...
Searching...
No Matches
Path Filtering

A path filter (fsw::monitor_filter) can be used to filter event paths. A filter type (fsw_filter_type) determines whether the filter regular expression is used to include and exclude paths from the list of the events processed by the library. By default, libfswatch uses the legacy filter mode and processes filters this way:

  • If a path matches an including filter, the path is accepted no matter any other filter.
  • If a path matches an excluding filter, the path is rejected.
  • If a path matches no lters, the path is accepted.

Said another way:

  • All paths are accepted by default, unless an exclusion filter says otherwise.
  • Inclusion filters may override any other exclusion filter.
  • The order in the filter definition has no effect.

The filter mode can be set to filter_mode_conjunctive to evaluate filters as a conjunction:

  • If no inclusion filters are specified, all paths are candidates.
  • If at least one inclusion filter is specified, a path must match at least one inclusion filter to be a candidate.
  • Any matching exclusion filter rejects the path.

Said another way, conjunctive mode accepts paths matching:

(no includes OR matches include) AND NOT matches exclude

Recursive Traversal Pruning

Prune filters are separate from path filters. A prune filter is a regular expression used by recursive monitors to decide whether traversal should descend into a non-root directory. When a directory is pruned, that directory's descendants are not scanned or monitored by implementations that traverse directory trees.

Pruning is applied before normal event filtering and is intentionally opt-in: unlike exclusion filters, prune filters can make included descendants impossible to observe.

Root paths are not pruned, even if they match a prune filter, because those paths were explicitly supplied by the caller.