isMatchGlob function

bool isMatchGlob(
  1. String pattern,
  2. String path
)

Checks if a path matches a glob pattern.

Uses package:glob syntax (e.g., *, ?, **). Returns true on match, false otherwise.

Example:

var matched = isMatchGlob('*.txt', 'file.txt'); // true
print(matched); // true
matched = isMatchGlob(r'/**/example/**', expandTilde('~/Downloads/ft/example/ft_example.dart'));
print(matched); // true, // startwith r'/**' is _patternCanMatchAbsolute
matched = isMatchGlob(r'?:/**/*.lnk', r'C:\Users\kaguya\Desktop\git-bash.lnk');
print(matched); //true, // windows startwith r'?:/**' is _patternCanMatchAbsolute
matched = isMatchGlob(r'**.dart', './example/ft_example.dart'));
print(matched); // true, // startwith r'**' is _patternCanMatchRelative

Implementation

bool isMatchGlob(String pattern, String path) => Glob(pattern).matches(path);