file_system_globbing library

Provides support for matching file system paths using glob patterns with include/exclude semantics.

This library enables pattern-based file matching inspired by Microsoft.Extensions.FileSystemGlobbing, supporting wildcards and directory recursion for flexible file selection.

Basic Glob Matching

Match files using glob patterns:

final matcher = Matcher()
  ..addInclude('**/*.dart')
  ..addExclude('**/*_test.dart');

final result = matcher.execute(DirectoryInfoWrapper(directory));

for (final file in result.files) {
  print(file.path);
}

Pattern Syntax

Supported glob pattern features:

  • * - matches any characters except directory separator
  • ** - matches any characters including directory separators
  • ? - matches any single character
  • [abc] - matches any character in the set
  • {a,b} - matches any of the alternatives

In-Memory Matching

Test glob patterns against in-memory directory structures:

final dir = InMemoryDirectoryInfo('/', [
  InMemoryFileInfo('file1.dart', dir),
  InMemoryFileInfo('file2.txt', dir),
]);

final matcher = Matcher()..addInclude('*.dart');
final result = matcher.execute(dir);

Classes

DirectoryInfoBase
Enumerates all files and directories in the directory.
DirectoryInfoWrapper
FileInfoBase
Represents a file
FileInfoWrapper
FilePatternMatch
Represents a file that was matched by searching using a globbing pattern
FileSystemInfoBase
Shared abstraction for files and directories
Glob
A glob for matching and listing files and directories.
InMemoryDirectoryInfo
Represents an in-memory directory for pattern matching without accessing the file system.
InMemoryFileInfo
Represents an in-memory file for pattern matching.
Matcher
Searches the file system for files with names that match specified patterns.
PatternMatchingResult
Represents a collection of FilePatternMatch

Extensions

MatcherExtensions on Matcher
Extension methods for Matcher to simplify common operations.