search
Searches for files matching a glob pattern, optionally recursively.
Signature
search(pattern: string, options?: SearchOptions): Result<string[], FsError>Options
SearchOptions is an interface with two optional fields:
recursive?: boolean, whentrue, searches subdirectories recursively. Defaults tofalse.maxResults?: u32, maximum number of results to return. Defaults to no limit.
Error handling
Returns Err(FsError) with code ERR_FS_SEARCH_FAILED if a directory cannot be listed or an entry cannot be inspected. A failed search does not return partial results; no matches produce Ok([]).
Example
tyrus
import { FsError, search } from "tyrus:fs";
match (search("*.txt", { recursive: true, maxResults: 100 })) {
Ok(matches) => { print(matches.length); } // 2
Err(error) => { printError(error.code); } // ERR_FS_SEARCH_FAILED
}