Path.iterdir

auto iterdir() const

Returns a lazy input range of Path values for each immediate entry in this directory, similar to Python's Path.iterdir().

Notes:

  • The range yields children in unspecified order (as provided by the

operating system). If you require deterministic ordering, collect to an array and sort.

  • This performs a shallow listing — it does not recurse.
  • Errors while iterating (e.g., permission denied mid-iteration) are

propagated by the underlying range operations when advanced.

Examples

import std.algorithm: map;
import std.array: array;
import std.path: baseName;
auto names = Path("/tmp").iterdir().map!(p => baseName(p.str())).array;
// sort if needed for deterministic order

Returns

A lazy range yielding Path elements.

Throws

If this is not a directory.