glob+x86_64 +linux
glob: pattern matching on file paths
The glob module provides an implementation of file globbing compatible with the behavior described by POSIX.
https://pubs.opengroup.org/onlinepubs/9699919799/functions/glob.html
Index
Types
type flag; // Undocumented types: type generator; type pattern; type strstack;
Errors
type failure;
Functions
fn finish(gen: *generator) void; fn glob(pattern: str, flags: flag = flag::NONE) (generator | nomem); fn next(gen: *generator) (str | done | failure | nomem); fn strerror(err: failure) str;
Types
type flag[permalink] [source]
type flag = enum uint { NONE = 0, // Slash appending is enabled. A slash character is appended to each // pathname that is a directory that matches the pattern. MARK = 1, // If the pattern does not match any pathname, the pattern string is // returned. NOCHECK = 1 << 1, // Backslash escaping is disabled. A backslash character is treated as // an ordinary character. NOESCAPE = 1 << 2, // Pathname sorting is disabled. The order of pathnames returned is // unspecified. NOSORT = 1 << 3, };
Flags used to control the behavior of next.
type generator[permalink] [source]
Show undocumented member
type generator = struct { pats: strstack, matc: size, flgs: flag, tmpp: pattern, };
type pattern[permalink] [source]
Show undocumented member
type pattern = struct { // TODO: look into working with a couple of string iterators instead dir: memio::stream, pat: memio::stream, rem: memio::stream, };
type strstack[permalink] [source]
Show undocumented member
type strstack = struct { bufv: []memio::stream, bufc: size, };
Errors
type failure[permalink] [source]
type failure = !struct { // The path that cannot be opened or read. path: str, // The actual filesystem error. error: fs::error, };
Information about an unsuccessful search.
Functions
fn finish[permalink] [source]
fn finish(gen: *generator) void;
Frees all memory allocated by the generator.
fn glob[permalink] [source]
fn glob(pattern: str, flags: flag = flag::NONE) (generator | nomem);
Returns a generator of pathnames matching a pattern. The result must be freed using finish.
fn next[permalink] [source]
fn next(gen: *generator) (str | done | failure | nomem);
Returns a generated pathname. The returned string is valid until next is called again. If, during the search, a directory is encountered that cannot be opened or read, a failure object is returned instead. If an error is returned, the generator should be considered invalid and cannot be used again, only freed using finish.
fn strerror[permalink] [source]
fn strerror(err: failure) str;
Converts a failure into a human-friendly string. The result is statically allocated.