Eager dirEntries

Andrej Mitrovic none at none.none
Mon Mar 21 16:26:37 PDT 2011


Currently we have DirEntries, which can be used in a foreach loop. We also have listDir, which returns a string[] with all entries found in a path. listDir is scheduled for deprecation, so I'm not using it.

DirEntries is definitely more flexible, but I can't eagerly construct an array of strings from it. For example, this won't compile:

string[] entries = array(dirEntries(directory, SpanMode.shallow));

Instead I have to expand the code to this:
string[] entries;
foreach (string name; dirEntries(directory, SpanMode.shallow))
{    
    entries ~= name;
}

That's just a waste of precious space. Would it be a good idea to make a feature request for this?


More information about the Digitalmars-d-learn mailing list