The way to traverse directories. See docs
do we need to follow symlinks of not. By default set to True.
// Iterate over paths in current directory foreach (p; Path.current.walk(SpanMode.breadth)) { if (p.isFile) writeln(p);
import dshould; Path root = createTempPath(); scope(exit) root.remove(); // Create sample directory structure root.join("d1", "d2").mkdir(true); root.join("d1", "test1.txt").writeFile("Test 1"); root.join("d1", "d2", "test2.txt").writeFile("Test 2"); // Walk through the derectory d1 Path[] result; foreach(p; root.join("d1").walk(SpanMode.breadth)) { result ~= p; } result.should.equal([ root.join("d1", "d2"), root.join("d1", "d2", "test2.txt"), root.join("d1", "test1.txt"), ]);
Iterate over all files and directories inside path;