Matcher class

Searches the file system for files with names that match specified patterns.

Patterns given to addInclude and addExclude are relative to the root directory passed to execute and can use the following formats:

  • exact names: "one.txt", "dir/two.txt"
  • * matches zero or more characters within a file or directory name: "*.txt", "readme.*", "styles/*.css"
  • ** matches an arbitrary number of directory levels: "**/*.cs", "dir/**/*"
  • .. at the beginning of a pattern refers to the parent directory
Available extensions

Constructors

Matcher({StringComparison comparisonType = StringComparison.ordinalIgnoreCase, bool preserveFilterOrder = false})
Creates a matcher.

Properties

comparisonType StringComparison
The string comparison used when matching patterns against names.
final
excludePatterns List<String>
The exclude pattern strings added so far.
no setter
hashCode int
The hash code for this object.
no setterinherited
includePatterns List<String>
The include pattern strings added so far.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addExclude(String pattern) Matcher
Adds a pattern for files the matcher should exclude from the results.
addExcludePatterns(Iterable<Iterable<String>> patterns) Matcher

Available on Matcher, provided by the MatcherExtensions extension

Adds multiple exclude patterns to the matcher.
addInclude(String pattern) Matcher
Adds a pattern for files the matcher should discover.
addIncludePatterns(Iterable<Iterable<String>> patterns) Matcher

Available on Matcher, provided by the MatcherExtensions extension

Adds multiple include patterns to the matcher.
execute(DirectoryInfoBase directoryInfo) PatternMatchingResult
Searches directoryInfo for all files matching the patterns added to this matcher.
getResultsInFullPath(String directoryPath, [FileSystem? fileSystem]) Iterable<String>

Available on Matcher, provided by the MatcherExtensions extension

Searches the directory for all files matching patterns and returns their full paths.
matchFile(String file, [String? root]) PatternMatchingResult

Available on Matcher, provided by the MatcherExtensions extension

Matches a single file path without accessing the file system.
matchFiles(Iterable<String> files, [String? root]) PatternMatchingResult

Available on Matcher, provided by the MatcherExtensions extension

Matches multiple file paths without accessing the file system.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited