Module fs/walker

fs/walker

Recursive directory traversal.

Example

{ walk, WalkEntry } :: import "std/fs/walker";

main :: (fn(using(io : IO)) -> unit)({
  given(exn) : Exception = {
    throw : (fn(forall(T : Type), error: AnyError) -> T)(
      { println(error.to_string()); exit(i32(1)); }
    )
  };

  entries := io.await(walk(`/tmp`));
  i := usize(0);
  while runtime((i < entries.len())), {
    e := entries.get(i).unwrap();
    println(e.path);
    i = (i + usize(1));
  };
});

Types

WalkEntry struct
WalkEntry

Entry returned by the directory walker.

Fields

NameTypeDescription
pathPath
nameString
depthu32
file_typeFileType
WalkOptions struct
WalkOptions

Options controlling directory walk behavior.

Fields

NameTypeDescription
max_depthOption(u32)
follow_symlinksbool
include_dirsbool
impl(WalkOptions, ...)
defaults : (WalkOptions) fn() -> WalkOptions

Returns: WalkOptions

Functions

walk function
fn(root : Path, using(io : IO)) -> Impl(Future(ArrayList(WalkEntry), IO, Exception))

Walk a directory tree with default options.

Parameters

NameTypeNotes
rootPath

Effects

NameTypeNotes
ioIOcomptime, implicit

Returns: Impl(Future(ArrayList(WalkEntry), IO, Exception))

walk_cstr function
fn(root : *(u8), using(io : IO)) -> Impl(Future(ArrayList(WalkEntry), IO, Exception))

Parameters

NameTypeNotes
root*(u8)

Effects

NameTypeNotes
ioIOcomptime, implicit

Returns: Impl(Future(ArrayList(WalkEntry), IO, Exception))

walk_with function
fn(root : Path, options : WalkOptions, using(io : IO)) -> Impl(Future(ArrayList(WalkEntry), IO, Exception))

Parameters

NameTypeNotes
rootPath
optionsWalkOptions

Effects

NameTypeNotes
ioIOcomptime, implicit

Returns: Impl(Future(ArrayList(WalkEntry), IO, Exception))

walk_with_cstr function
fn(root : *(u8), options : WalkOptions, using(io : IO)) -> Impl(Future(ArrayList(WalkEntry), IO, Exception))

Parameters

NameTypeNotes
root*(u8)
optionsWalkOptions

Effects

NameTypeNotes
ioIOcomptime, implicit

Returns: Impl(Future(ArrayList(WalkEntry), IO, Exception))