diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-10-29 14:36:49 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-10-29 14:36:49 -0400 |
| commit | 7cd67dd7f3ebf38a2a65c6756090936f9a1b3b03 (patch) | |
| tree | 6407b1b0836ea0d474b4822ef888cb6c6eaba7ae /docs/paths.md | |
| parent | e3c1dd2df5a593829a4d5864f8ff7ea4582da55c (diff) | |
Add file globbing
Diffstat (limited to 'docs/paths.md')
| -rw-r--r-- | docs/paths.md | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/docs/paths.md b/docs/paths.md index 8fb427b2..86ec2f26 100644 --- a/docs/paths.md +++ b/docs/paths.md @@ -288,6 +288,53 @@ A list of file paths. --- +### `glob` + +**Description:** +Perform a globbing operation and return an array of matching paths. Some glob +specific details: + +- The paths "." and ".." are *not* included in any globbing results. +- Files or directories that begin with "." will not match `*`, but will match `.*`. +- Globs do support `{a,b}` syntax for matching files that match any of several + choices of patterns. +- The shell-style syntax `**` for matching subdirectories is not supported. + +**Signature:** +```tomo +func glob(path: Path -> [Path]) +``` + +**Parameters:** + +- `path`: The path of the directory which may contain special globbing characters + like `*`, `?`, or `{...}` + +**Returns:** +A list of file paths that match the glob. + +**Example:** +```tomo +# Current directory includes: foo.txt, baz.txt, qux.jpg, .hidden +>> (./*):glob() += [(./foo.txt), (./baz.txt), (./qux.jpg)] + +>> (./*.txt):glob() += [(./foo.txt), (./baz.txt)] + +>> (./*.{txt,jpg}):glob() += [(./foo.txt), (./baz.txt), (./qux.jpg)] + +>> (./.*):glob() += [(./.hidden)] + +# Globs with no matches return an empty array: +>> (./*.xxx):glob() += [] +``` + +--- + ### `is_directory` **Description:** |
