Utility changes to support extracting a zip relative to a mod. Can also be used to install new mods.

This commit is contained in:
Paul Chote
2010-11-25 15:44:59 +13:00
parent dcf3912d24
commit d6e831eb07
2 changed files with 22 additions and 10 deletions

View File

@@ -52,6 +52,24 @@ namespace OpenRA.Utility
}
}
public static void ExtractZip(string argValue)
{
string[] args = argValue.Split(',');
if (args.Length != 3)
{
Console.WriteLine("Error: invalid syntax");
return;
}
string zipFile = args[0];
string mod = args[1];
string path = args[2];
if (!File.Exists(zipFile)) { Console.WriteLine("Error: Could not find {0}", zipFile); return; }
string dest = "mods{0}{1}{0}{2}".F(Path.DirectorySeparatorChar,mod,path);
new ZipInputStream(File.OpenRead(zipFile)).ExtractZip(dest);
}
public static void DownloadUrl(string argValue)
{
string[] args = argValue.Split(',');
@@ -170,11 +188,5 @@ namespace OpenRA.Utility
Console.WriteLine(n.Value);
}
public static void InstallMod(string zipFile)
{
if (!File.Exists(zipFile)) { Console.WriteLine("Error: Could not find {0}", zipFile); return; }
new ZipInputStream(File.OpenRead(zipFile)).ExtractZip("mods");
}
}
}