globMatcher

fun globMatcher(pattern: String): (Path) -> Boolean

Builds a test that tells whether a path matches pattern, using the same glob rules as ripgrep and .gitignore.

The glob is turned into one regular expression (see globToRegex). Because of that, every "**/" in the pattern matches zero or more folders on its own, however many there are: "a/**/b/**/c" matches "a/b/c", "a/x/b/c", "a/b/y/c", and so on, all at once. The rest of the glob works as usual: "*" and "?" stay inside one folder or file name, and "{a,b}" choices and "a-z"/"!a" character sets keep working. A pattern starting with "regex:" is used as-is.

Matching is case-sensitive on every platform, for cross-platform determinism: results depend only on the pattern, not the host OS. (NIO's getPathMatcher was case-insensitive on Windows.) For case-insensitivity, spell it out in the glob, e.g. "*.{kt,KT}".