Skip to main content

glob

function

babashka.fs/glob

(glob [root pattern] [root pattern opts])
Returns a vector of paths matching glob `pattern` (on path and filename) relative to `root` dir. Patterns containing `**` or `/` will cause a recursive walk under `root`, unless overriden with `:recursive false`. Similarly, `:hidden` will be automaticaly enabled when `pattern` starts with a dot. Glob interpretation is done using the rules described in [FileSystem#getPathMatcher](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/FileSystem.html#getPathMatcher(java.lang.String)) Options: * `:hidden` - match hidden paths. Implied `true` when `pattern` starts with a dot; otherwise, defaults to `false`. Note: on Windows files starting with a dot are not hidden, unless their hidden attribute is set. * [`:follow-links`](/README.md#follow-links) - follow symlinks. Defaults to `false`. * `:recursive` - Implied `true` when `pattern` contains `**` or `/`; otherwise, defaults to `false`. * `true` - `pattern` is matched against all descendant files and directories under `root` * `false` - `pattern` is matched only against immediate children under `root` * `:max-depth` - max depth to descend into directory structure, when recursing. Defaults to `Integer/MAX_VALUE`. Examples: - `(fs/glob "." "**.clj")` - finds `.clj` files and dirs under `.` dir and its subdirs - `(fs/glob "." "**.clj" {:recursive false})` - finds `.clj` files and dirs immediately under `.` dir only - `(fs/glob "." "*.clj" {:recursive true})` - finds `.clj` files and dirs immediately under `.` only (`pattern` lacks directory wildcards) See also: [[match]]

No examples yet. Be the first to add one!