123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 | '\" t
.\" Copyright (c) 2026 Bruce Hill
.\" All rights reserved.
.\"
.TH Path.each_child 3 2026-09-01 "Tomo man-pages"
.SH NAME
Path.each_child \- iterate over children of a directory
.SH LIBRARY
Tomo Standard Library
.SH SYNOPSIS
.nf
.BI Path.each_child\ :\ func(path:\ Path,\ include_hidden:\ Bool\ =\ no\ ->\ func(->Path?)?)
.fi
.SH DESCRIPTION
Returns an iterator over the children (files and directories) within the directory at the specified path. Optionally includes hidden files. Iteration order is not specified.
.SH ARGUMENTS
.TS
allbox;
lb lb lbx lb
l l l l.
Name Type Description Default
path Path The path of the directory. -
include_hidden Bool Whether to include hidden files (those starting with a \fB.\fR). no
.TE
.SH RETURN
An iterator over the children in a directory, or `none` if the directory could not be read.
.SH NOTES
The paths returned keep the form of the path they came from: the children of `(./foo)` are relative and the children of `(~/foo)` stay home-based. Use `.resolved()` on them if you need absolute paths.
.SH ERRORS
Returns `none` if the path is not a readable directory.
.SH EXAMPLES
.EX
# Safely handle the directory not being readable:
if children := (/dir).each_child()
for child in children
say("Child: $child")
else
say("Couldn't read the directory!")
# Assume the directory is readable and error if that's not the case:
for child in (/dir).each_child()!
say("Child: $child")
.EE
.SH SEE ALSO
.BR Tomo-Path (3)
|