mirror of
https://git.proxmox.com/git/pathpatterns
synced 2025-07-13 19:39:05 +00:00
add MatchPattern::Literal
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
e2255d72d1
commit
e86ed76048
@ -48,6 +48,9 @@ impl Default for MatchFlag {
|
||||
pub enum MatchPattern {
|
||||
/// A glob pattern.
|
||||
Pattern(crate::Pattern),
|
||||
|
||||
/// A literal match.
|
||||
Literal(Vec<u8>),
|
||||
}
|
||||
|
||||
impl From<crate::Pattern> for MatchPattern {
|
||||
@ -56,6 +59,12 @@ impl From<crate::Pattern> for MatchPattern {
|
||||
}
|
||||
}
|
||||
|
||||
impl MatchPattern {
|
||||
pub fn literal(literal: impl Into<Vec<u8>>) -> Self {
|
||||
MatchPattern::Literal(literal.into())
|
||||
}
|
||||
}
|
||||
|
||||
/// A pattern can be used as an include or an exclude pattern. In a list of `MatchEntry`s, later
|
||||
/// patterns take precedence over earlier patterns and the order of includes vs excludes makes a
|
||||
/// difference.
|
||||
@ -234,6 +243,7 @@ impl MatchEntry {
|
||||
fn matches_path_exact_do(&self, path: &[u8]) -> bool {
|
||||
match &self.pattern {
|
||||
MatchPattern::Pattern(pattern) => pattern.matches(path),
|
||||
MatchPattern::Literal(literal) => path == &literal[..],
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user