iterate over a directory, dealing with permission errors
Adrian Matoga via Digitalmars-d
digitalmars-d at puremagic.com
Fri Sep 18 05:09:08 PDT 2015
On Friday, 18 September 2015 at 11:54:32 UTC, Robert burner
Schadek wrote:
> http://dlang.org/phobos/std_exception.html#.handle
>
> foreach(file; dirEntries(args[1], SpanMode.depth)
> .handle!(Exception, RangePrimitive.front, (e, r) =>
> DirEntry())) {
> writeln(file.name);
> }
>
> change Exception to the Exception Type to handle and select the
> throwing range primitive (RangePrimitive). Then just supply a
> delegate that does the actual handling.
> This will not break any range chain!
Cool, I wish I had this idea back in 2012.
More information about the Digitalmars-d
mailing list