Reputation: 19
Under linux, I do the following
COMMAND /home/directory/*.txt
and all the files in that directory get passed as separate parameters (20 files in the directory results in 20 parameters in the argv variable)
Under windows, the same command results in one parameter (that string exactly).
Is this a compiler issue (VisualC++ 2008) or a windows thing or what?
In the past, I've written batch files to parse the files into multiple parameters, but I'm hoping there's a better way.
Any help would be appreciated
Upvotes: 0
Views: 184
Reputation: 201672
Indeed that is a shell globbing feature. In PowerShell you would handle wildcard expansion inside your function using Convert-Path
(or Resolve-Path) e.g.:
function ITakeWildcards([string]$Path) {
$paths = Convert-Path $path
foreach ($aPath in $paths) {
"Processing path $aPath"
}
}
Upvotes: 0
Reputation: 490148
It's somewhat more limited than most Unix shells, but VC++ includes a file named setargv.obj
that you can link with to add globbing to your application. It supports *
and ?
, which covers most of what most people care about.
To use it, just include setargv.obj
when you link your file. In most cases, this just means adding the file name to the command line, something like this:
cl myfile.c myotherfile.c setargv.obj
Upvotes: 2