Value | Meaning |
---|---|
shallow | Only spans one directory. |
depth | Spans the directory in _depth-first post-order, i.e. the content of any subdirectory is spanned before that subdirectory itself. Useful e.g. when recursively deleting files. |
breadth | Spans the directory in depth-first pre-order, i.e. the content of any subdirectory is spanned right after that subdirectory itself. Note that SpanMode.breadth will not result in all directory members occurring before any subdirectory members, i.e. it is not _true _breadth-first traversal. |
import std.algorithm.comparison : equal; import std.algorithm.iteration : map; import std.algorithm.sorting : sort; import std.array : array; import std.path : buildPath, relativePath; auto root = deleteme ~ "root"; scope(exit) root.rmdirRecurse; root.mkdir; root.buildPath("animals").mkdir; root.buildPath("animals", "cat").mkdir; alias removeRoot = (return scope e) => e.relativePath(root); assert(root.dirEntries(SpanMode.depth).map!removeRoot.equal( [buildPath("animals", "cat"), "animals"])); assert(root.dirEntries(SpanMode.breadth).map!removeRoot.equal( ["animals", buildPath("animals", "cat")])); root.buildPath("plants").mkdir; assert(root.dirEntries(SpanMode.shallow).array.sort.map!removeRoot.equal( ["animals", "plants"]));
Dictates directory spanning policy for dirEntries (see below).