glob
Matches file and directory names against a glob pattern. The pattern is resolved against the process working directory before matching. Relative patterns return relative paths, while absolute patterns return absolute paths. Supports * (matches any characters except /) and ** (matches any number of directories).
Signature
glob(pattern: string): Result<string[], FsError>Error handling
Returns Err(FsError) with code ERR_FS_GLOB_FAILED if a directory cannot be listed or an entry needed for traversal cannot be inspected. A failed traversal does not return partial matches; no matches produce Ok([]).
Example
tyrus
import { FsError, glob } from "tyrus:fs";
match (glob("*.txt")) {
Ok(files) => { print(files.length); } // 2
Err(error) => { printError(error.code); } // ERR_FS_GLOB_FAILED
}
match (glob("./src/**/*.ts")) {
Ok(pyFiles) => { print(pyFiles.length); } // 4
Err(error) => { printError(error.code); } // ERR_FS_GLOB_FAILED
}