Below is a code fragment I'm using to expand pathname argv args in some
directory processing code. Works pretty well. Basically, I'm allowing
expansion of just the basename; so strings like these below are expanded into
expDir[] for each matching path in the dirname directory, which is determined
by the shallow spanmode. The last arg to dirEntries determines whether it
follows links. In this case I'm not following them.
c:\dir1\xx*
c:\dir2\x?d
There is a special dirEntries call that appears to be intended exactly for
this. You need to include std.file and std.path
string[] expDirs; // expanded directories from wildargv
expansion on arg
string basename = baseName(arg);
string dirname = dirName(arg);
// expand the wildargs for the single level. Don't follow links
auto dFiles =
dirEntries(dirname,basename,SpanMode.shallow,false);
foreach(d; dFiles){
expDirs ~= d.name;
}