Class Matcher
- Namespace
- Acuit.Pinpoint.FileSystemGlobbing
- Assembly
- Acuit.Pinpoint.Configuration.dll
Searches the file system for files with names that match specified patterns.
public class Matcher
- Inheritance
-
Matcher
- Inherited Members
- Extension Methods
Remarks
Patterns specified in AddInclude(string) and AddExclude(string) can use the following formats to match multiple files or directories.
-
exact directory and file name
- "one.txt"
- "dir/two.txt"
-
wildcards (*) in file and directory names that represent zero to many characters not including
directory separators characters
- "*.txt"all files with .txt file extension
- "*.*"all files with an extension
- "*"all files in top level directory
- ".*"filenames beginning with '.'
- "readme.*"all files named 'readme' with any file extension
- "styles/*.css"all files with extension '.css' in the directory 'styles/'
- "scripts/*/*"all files in 'scripts/' or one level of subdirectory under 'scripts/'
- "images*/*"all files in a folder with name that is or begins with 'images'
- arbitrary directory depth ("/**/")
- "**/*"all files in any subdirectory
- "dir/**/*"all files in any subdirectory under 'dir/'
- relative paths '../shared/*' - all files in a diretory named 'shared' at the sibling level to the base directory given to Execute(DirectoryInfoBase)
Constructors
Matcher()
Initializes an instance of Matcher using case-insensitive matching
public Matcher()
Matcher(StringComparison)
Initializes an instance of Matcher using the string comparsion method specified
public Matcher(StringComparison comparisonType)
Parameters
comparisonType
StringComparisonThe StringComparison to use
Methods
AddExclude(string)
Add a file name pattern for files the matcher should exclude from the results. Patterns are relative to the root directory given when Execute(DirectoryInfoBase) is called.
Use the forward slash '/' to represent directory separator. Use '*' to represent wildcards in file and directory names. Use '**' to represent arbitrary directory depth. Use '..' to represent a parent directory.
public virtual Matcher AddExclude(string pattern)
Parameters
pattern
stringThe globbing pattern
Returns
- Matcher
The matcher
AddInclude(string)
Add a file name pattern that the matcher should use to discover files. Patterns are relative to the root directory given when Execute(DirectoryInfoBase) is called.
Use the forward slash '/' to represent directory separator. Use '*' to represent wildcards in file and directory names. Use '**' to represent arbitrary directory depth. Use '..' to represent a parent directory.
public virtual Matcher AddInclude(string pattern)
Parameters
pattern
stringThe globbing pattern
Returns
- Matcher
The matcher
Execute(DirectoryInfoBase)
Searches the directory specified for all files matching patterns added to this instance of Matcher
public virtual PatternMatchingResult Execute(DirectoryInfoBase directoryInfo)
Parameters
directoryInfo
DirectoryInfoBaseThe root directory for the search
Returns
- PatternMatchingResult
Always returns instance of PatternMatchingResult, even if not files were matched