Shuffle
Brad Roberts
braddr at puremagic.com
Thu Jan 24 23:15:29 PST 2008
Walter Bright wrote:
> eao197 wrote:
>> I think than the code could be yet more compact, simple and
>> script-like if std.file (or std.path) module will contain something
>> like Dir.glob from Ruby
>> (http://www.ruby-doc.org/core/classes/Dir.html#M002347)
>
> I agree.
Part of it already exists in 2.0, in the std.file.dirEntries and
.DirIterator code. It needs to take a delegate or other filter
mechanism to gain the rest of the power. But as is it'd simply the
example of a bit of it (untested).
string[] files;
foreach (DirEntry de; dirEntries(fromdir, SpanMode.depth))
{
// Collect only files with mp3 and wma extensions
auto ext = getExt(de.name);
if (fnmatch(ext, "mp3") || fnmatch(ext, "wma"))
files ~= de.name;
}
Later,
Brad
More information about the Digitalmars-d-announce
mailing list