convert FileExtractor into a Utility cmdlet
This commit is contained in:
@@ -128,5 +128,24 @@ namespace OpenRA.Utility
|
||||
ShpWriter.Write(destStream, size.Width, size.Height,
|
||||
srcImage.Select( im => im.Image ));
|
||||
}
|
||||
|
||||
public static void ExtractFiles(string[] args)
|
||||
{
|
||||
var mods = args[1].Split(',');
|
||||
var files = args.Skip(2);
|
||||
|
||||
var manifest = new Manifest(mods);
|
||||
FileSystem.LoadFromManifest(manifest);
|
||||
|
||||
foreach( var f in files )
|
||||
{
|
||||
var src = FileSystem.Open(f);
|
||||
if (src == null)
|
||||
throw new InvalidOperationException("File not found: {0}".F(f));
|
||||
var data = src.ReadAllBytes();
|
||||
|
||||
File.WriteAllBytes( f, data );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace OpenRA.Utility
|
||||
{ "--shp", Command.ConvertPngToShp },
|
||||
{ "--png", Command.ConvertShpToPng },
|
||||
{ "--fromd2", Command.ConvertFormat2ToFormat80 },
|
||||
{ "--extract", Command.ExtractFiles },
|
||||
};
|
||||
|
||||
if (args.Length == 0) { PrintUsage(); return; }
|
||||
@@ -57,6 +58,7 @@ namespace OpenRA.Utility
|
||||
Console.WriteLine(" --settings-value KEY Get value of KEY from settings.yaml");
|
||||
Console.WriteLine(" --shp PNGFILE FRAMEWIDTH Convert a PNG containing one or more frames to a SHP");
|
||||
Console.WriteLine(" --png SHPFILE PALETTE Convert a SHP to a PNG containing all of its frames");
|
||||
Console.WriteLine(" --extract MOD[,MOD]* FILES Extract files from mod packages");
|
||||
}
|
||||
|
||||
static T WithDefault<T>(T def, Func<T> f)
|
||||
|
||||
Reference in New Issue
Block a user