February 15, 2012
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;

February 15, 2012
So, there are some wildargv C  implementations around that can substitue for the argv initializations, which would provide argv expansion before it got to main.  Are there any options for argv expansion in the D libraries.   I suppose in linux this is all supplied by the shell, but in Windows it would help to have optional argv expansion.
Top | Discussion index | About this forum | D home