glob +linux +x86_64

The glob module provides an implementation of file globbing compatible with the behavior described by POSIX.



type flags;

// Undocumented types:
type generator;
type pattern;
type strstack;


type failure;


fn finish(*generator) void;
fn glob(str, flags...) generator;
fn next(*generator) (str | void | failure);


type flags[link]

type flags = 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[link]

Show undocumented member
type generator = struct {
	pats: strstack,
	matc: size,
	flgs: flags,
	tmpp: pattern,

type pattern[link]

Show undocumented member
type pattern = struct {
	dir: strio::stream,
	pat: strio::stream,
	rem: strio::stream,

type strstack[link]

Show undocumented member
type strstack = struct {
	bufv: []strio::stream,
	bufc: size,


type failure[link]

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.


fn finish[link]

fn finish(gen: *generator) void;

Frees all memory allocated by the generator.

fn glob[link]

fn glob(pattern: str, flags: flags...) generator;

Returns a generator of pathnames matching a pattern. The result must be freed using finish.

fn next[link]

fn next(gen: *generator) (str | void |

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.