On Jul 17, 11 23:28, Robert Clipsham wrote:
Also note that you can't use dirEntries() ~ dirEntries() or
chain(dirEntries(), dirEntries()) as DirIterator is not a range.

This compiles and runs for me:

-----------------------------------
import std.file, std.range, std.algorithm, std.stdio;
void main() {
auto dFiles = filter!`endsWith(a.name, ".d")`(dirEntries(".", SpanMode.depth)); auto cFiles = filter!`endsWith(a.name, ".c")`(dirEntries("./foo", SpanMode.depth));

    foreach (file; chain(dFiles, cFiles)) {
        writeln(file.name);
    }
}
-----------------------------------

The problem is *not* DirIterator not being a range, but that DirIterator is not a range of *string*. The foreach loop you're using

    foreach (string file; obj) { ... }

requires an *opApply* which outputs strings from 'obj', but the range interface of 'DirIterator' outputs 'DirEntry'.

Reply via email to