glob
Index
Types
type flag = enum uint {
NONE = 0,
MARK = 1,
NOCHECK = 1 << 1,
NOESCAPE = 1 << 2,
NOSORT = 1 << 3,
};
type generator = struct {
pats: strstack,
matc: size,
flgs: flag,
tmpp: pattern,
};
type pattern = struct {
dir: memio::stream,
pat: memio::stream,
rem: memio::stream,
};
type strstack = struct {
bufv: []memio::stream,
bufc: size,
};
Errors
type failure = !struct {
path: str,
error: fs::error,
};
Functions
fn finish(gen: *generator) void;
fn glob(pattern: str, flags: flag = flag::NONE) generator;
fn next(gen: *generator) (str | done | failure);
fn strerror(err: failure) str;
Types
type flag
type flag = enum uint {
NONE = 0,
MARK = 1,
NOCHECK = 1 << 1,
NOESCAPE = 1 << 2,
NOSORT = 1 << 3,
};
Flags used to control the behavior of next.
type generator
Show undocumented member
type generator = struct {
pats: strstack,
matc: size,
flgs: flag,
tmpp: pattern,
};
type pattern
Show undocumented member
type pattern = struct {
dir: memio::stream,
pat: memio::stream,
rem: memio::stream,
};
type strstack
Show undocumented member
type strstack = struct {
bufv: []memio::stream,
bufc: size,
};
Errors
type failure
type failure = !struct {
path: str,
error: fs::error,
};
Information about an unsuccessful search.
Functions
fn finish
fn finish(gen: *generator) void;
Frees all memory allocated by the generator.
fn glob
fn glob(pattern: str, flags: flag = flag::NONE) generator;
Returns a generator of pathnames matching a pattern. The result must be freed using finish.
fn next
fn next(gen: *generator) (str | done | failure);
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. next can be repeatedly called until void is returned.
fn strerror
fn strerror(err: failure) str;
Converts an error info a human-friendly string. The result is statically allocated.