Strip installer functionality from Utility

This commit is contained in:
Paul Chote
2011-05-04 13:44:00 +12:00
parent 83c026e12b
commit 96c3679cc9
4 changed files with 1 additions and 253 deletions

View File

@@ -25,92 +25,6 @@ namespace OpenRA.Utility
{
static class Command
{
public static void ExtractZip(string[] args)
{
if (args.Length < 3)
{
Console.WriteLine("Error: Invalid syntax");
return;
}
var zipFile = args[1];
var dest = args[2];
if (!File.Exists(zipFile))
{
Console.WriteLine("Error: Could not find {0}", zipFile);
return;
}
List<string> extracted = new List<string>();
try
{
new ZipInputStream(File.OpenRead(zipFile)).ExtractZip(dest, extracted);
}
catch (SharpZipBaseException)
{
foreach(var f in extracted)
File.Delete(f);
Console.WriteLine("Error: Corrupted archive");
return;
}
Console.WriteLine("Status: Completed");
}
static void InstallPackages(string fromPath, string toPath,
string[] filesToCopy, string[] filesToExtract, string packageToMount)
{
if (!Directory.Exists(toPath))
Directory.CreateDirectory(toPath);
Util.ExtractFromPackage(fromPath, packageToMount, filesToExtract, toPath);
foreach (var file in filesToCopy)
{
if (!File.Exists(Path.Combine(fromPath, file)))
{
Console.WriteLine("Error: Could not find {0}", file);
return;
}
Console.WriteLine("Status: Extracting {0}", file.ToLowerInvariant());
File.Copy(
Path.Combine(fromPath, file),
Path.Combine(toPath, Path.GetFileName(file).ToLowerInvariant()), true);
}
Console.WriteLine("Status: Completed");
}
public static void InstallRAPackages(string[] args)
{
if (args.Length < 3)
{
Console.WriteLine("Error: Invalid syntax");
return;
}
InstallPackages(args[1], args[2],
new string[] { "INSTALL/REDALERT.MIX" },
new string[] { "conquer.mix", "russian.mix", "allies.mix", "sounds.mix",
"scores.mix", "snow.mix", "interior.mix", "temperat.mix" },
"MAIN.MIX");
}
public static void InstallCncPackages(string[] args)
{
if (args.Length < 3)
{
Console.WriteLine("Error: Invalid syntax");
return;
}
InstallPackages(args[1], args[2],
new string[] { "CONQUER.MIX", "DESERT.MIX", "GENERAL.MIX", "SCORES.MIX",
"SOUNDS.MIX", "TEMPERAT.MIX", "WINTER.MIX" },
new string[] { "cclocal.mix", "speech.mix", "tempicnh.mix", "updatec.mix" },
"INSTALL/SETUP.Z");
}
public static void DisplayFilepicker(string[] args)
{
if (args.Length < 2)
@@ -140,17 +54,6 @@ namespace OpenRA.Utility
Console.WriteLine(result);
}
static void AuthenticateAndExecute(string cmd, string[] args)
{
for (var i = 1; i < args.Length; i++)
cmd += " \"{0}\"".F(args[i]);
Util.CallWithAdmin(cmd);
}
public static void AuthenticateAndExtractZip(string[] args) { AuthenticateAndExecute("--extract-zip-inner", args); }
public static void AuthenticateAndInstallRAPackages(string[] args) { AuthenticateAndExecute( "--install-ra-packages-inner", args ); }
public static void AuthenticateAndInstallCncPackages(string[] args) { AuthenticateAndExecute( "--install-cnc-packages-inner", args ); }
public static void ConvertPngToShp(string[] args)
{
var src = args[1];