View source code
Display the source code in std/file.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Enum std.file.SpanMode
Dictates directory spanning policy for dirEntries (see below).
enum SpanMode
: int { ... }
Enum members
Name | Description |
---|---|
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 |
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. |
shallow
|
Only spans one directory. |
Example
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"]));
Authors
License
Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.