Glob class

A glob for matching and listing files and directories.

A glob matches an entire string as a path. Although the glob pattern uses POSIX syntax, it can match against POSIX, Windows, or URL paths. The format it expects paths to use is based on the context parameter to Glob.new; it defaults to the current system's syntax.

Paths are normalized before being matched against a glob, so for example the glob foo/bar matches the path foo/./bar. A relative glob can match an absolute path and vice versa; globs and paths are both interpreted as relative to context.current, which defaults to the current working directory.

When used as a Pattern, a glob will return either one or zero matches for a string depending on whether the entire string matches the glob. These matches don't currently have capture groups, although this may change in the future.

Implemented types
Available Extensions

Constructors

Glob(String pattern, {Context? context, bool recursive = false, bool? caseSensitive})
Creates a new glob with pattern.
factory

Properties

caseSensitive bool
Whether the glob matches paths case-sensitively.
no setter
context → Context
The context in which paths matched against this glob are interpreted.
final
hashCode int
The hash code for this object.
no setterinherited
pattern String
The pattern used to create this glob.
final
recursive bool
If true, a path matches if it matches the glob itself or is recursively contained within a directory that matches.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

allMatches(String path, [int start = 0]) Iterable<Match>
Matches this pattern against the string repeatedly.
override
listFileSystem(FileSystem fileSystem, {String? root, bool followLinks = true}) Stream<FileSystemEntity>
Lists all FileSystemEntitys beneath root that match the glob in the provided fileSystem.
listFileSystemSync(FileSystem fileSystem, {String? root, bool followLinks = true}) List<FileSystemEntity>
Synchronously lists all FileSystemEntitys beneath root that match the glob in the provided fileSystem.
matchAsPrefix(String path, [int start = 0]) Match?
Matches this pattern against the start of string.
override
matches(String path) bool
Returns whether this glob matches path.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

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

Static Methods

quote(String contents) String
Returns contents with characters that are meaningful in globs backslash-escaped.