prune with dirEntries
Joshua Niehus
jm.niehus at gmail.com
Thu Nov 29 22:28:56 PST 2012
On Friday, 30 November 2012 at 01:57:21 UTC, Dan wrote:
> That will do the filtering correctly - but what I was hoping
> was to actually prune at the directory level and not drill down
> to the files in of an unwanted directory (e.g. .git). The
> problem with this and what I'm trying to overcome is accessing
> lots of files and directories recursively all of which I want
> to skip. Much like there is a *followSymlink* it would be nice
> if a predicate were accepted to *followDirectory* in general or
> some way to cause that.
what about the following?
import std.algorithm, std.array, std.regex;
import std.stdio, std.file;
void main()
{
auto exclude = regex(r"\.git", "g");
dirEntries("/path/GIT", SpanMode.breadth)
.filter!(a => match(a.name, exclude).empty)
.writeln();
}
I think if you go breadth first, you can filter out the unwanted
directories before it delves into them
More information about the Digitalmars-d-learn
mailing list