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 .path : buildPath, relativePath;
auto root = deleteme ~ "root";
scope(exit) root .rmdirRecurse;
root .mkdir;
root .buildPath("animals") .mkdir;
root .buildPath("animals", "cat") .mkdir;
root .buildPath("animals", "dog") .mkdir;
root .buildPath("plants") .mkdir;
alias removeRoot = (e) => e .relativePath(root);
root .dirEntries(SpanMode .shallow) .map!removeRoot .equal(
["plants", "animals"]);
root .dirEntries(SpanMode .depth) .map!removeRoot .equal(
["plants", "animals/dog", "animals/cat", "animals"]);
root .dirEntries(SpanMode .breadth) .map!removeRoot .equal(
["plants", "animals", "animals/dog", "animals/cat"]);
Authors
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.