Expand description
Pattern-based file filtering for include/exclude operations
This module provides glob pattern matching for filtering files during copy, link, and remove operations.
§Pattern Syntax
*matches anything except/**matches anything including/(crosses directories)?matches a single character (except/)[...]character classes- Leading
/anchors to source root - Trailing
/matches only directories
§Examples
use common::filter::{FilterSettings, FilterResult};
use std::path::Path;
let mut settings = FilterSettings::default();
settings.add_exclude("*.log").unwrap();
settings.add_exclude("target/").unwrap();
// .log files are excluded
assert!(matches!(
settings.should_include(Path::new("debug.log"), false),
FilterResult::ExcludedByPattern(_)
));
// other files are included
assert!(matches!(
settings.should_include(Path::new("main.rs"), false),
FilterResult::Included
));Structs§
- Filter
Pattern - A compiled filter pattern with metadata about its original form
- Filter
Settings - Settings for filtering files based on include/exclude patterns
- Time
Filter - Time-based filter for matching entries by age (mtime/btime).
Enums§
- Filter
Result - Result of checking whether a path should be included
- Time
Filter Result - Outcome of evaluating a
TimeFilteragainst a metadata entry. - Time
Skip Reason - Why an entry was skipped by a
TimeFilter— the subset ofTimeFilterResultthat does not includeMatched. Constructed viaTimeFilterResult::as_skip_reason.
Functions§
- reject_
created_ before_ on_ musl - Reject
--created-beforeon musl builds, where birth time (btime) is unreadable viastd::fs::Metadata::created()so every entry would fail evaluation and be skipped. No-op on glibc.toolnames the binary for the error message.