Fixes #4615: OpenRA.Utility should expand wildcards in paths

The path to be expanded. It can be a relative or an absolute path.
Wildcards can appear as part of the path and as part of the file name/extension.

Example:

	Expand("./mods/*/mod.?aml");
This commit is contained in:
Pavlos Touboulidis
2014-05-07 20:32:54 +03:00
parent 0f591bb3ba
commit 5fc7ef02bf
3 changed files with 140 additions and 2 deletions

View File

@@ -31,6 +31,13 @@ namespace OpenRA.Utility
{
public static class Command
{
static IEnumerable<string> GlobArgs(string[] args, int startIndex = 1)
{
for (var i = startIndex; i < args.Length; i++)
foreach (var path in Glob.Expand(args[i]))
yield return path;
}
[Desc("KEY", "Get value of KEY from settings.yaml")]
public static void Settings(string[] args)
{
@@ -50,8 +57,9 @@ namespace OpenRA.Utility
[Desc("PNGFILE [PNGFILE ...]", "Combine a list of PNG images into a SHP")]
public static void ConvertPngToShp(string[] args)
{
var dest = args[1].Split('-').First() + ".shp";
var frames = args.Skip(1).Select(a => PngLoader.Load(a));
var inputFiles = GlobArgs(args).OrderBy(a => a).ToList();
var dest = inputFiles[0].Split('-').First() + ".shp";
var frames = inputFiles.Select(a => PngLoader.Load(a));
var size = frames.First().Size;
if (frames.Any(f => f.Size != size))