Utility now uses named pipe if passed --pipe. Installing mods now works properly too.

This commit is contained in:
Matthew Bowra-Dean
2010-11-05 15:24:32 +13:00
committed by Paul Chote
parent da384af339
commit 0c319e88c3
7 changed files with 77 additions and 33 deletions

View File

@@ -41,9 +41,14 @@ namespace OpenRA.Launcher
Mod GetMetadata(string mod)
{
var response = UtilityProgram.Call("-i", mod);
if (response.IsError) return null;
string[] lines = response.ResponseLines;
string responseString;
using (var response = UtilityProgram.Call("-i", mod))
{
responseString = response.ReadToEnd();
}
if (Util.IsError(ref responseString)) return null;
string[] lines = responseString.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
string title = "", version = "", author = "", description = "", requires = "";
bool standalone = false;
@@ -83,12 +88,17 @@ namespace OpenRA.Launcher
void RefreshMods()
{
var response = UtilityProgram.Call("--list-mods");
string responseString;
using (var response = UtilityProgram.Call("--list-mods"))
{
responseString = response.ReadToEnd();
}
string[] mods;
if (!response.IsError)
mods = response.ResponseLines;
if (!Util.IsError(ref responseString))
mods = responseString.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
else
throw new Exception(string.Format("Could not list mods: {0}", response.Response));
throw new Exception(string.Format("Could not list mods: {0}", responseString));
allMods = mods.ToDictionary(x => x, x => GetMetadata(x));
@@ -98,8 +108,12 @@ namespace OpenRA.Launcher
private void InstallMod(object sender, EventArgs e)
{
if (installModDialog.ShowDialog() != DialogResult.OK) return;
UtilityProgram.CallWithAdmin("--install-mods", installModDialog.FileName);
RefreshModTree(treeView1, allMods.Keys.ToArray());
using (var response = UtilityProgram.CallWithAdmin("--install-mod", installModDialog.FileName))
{
string s = response.ReadToEnd();
}
RefreshMods();
}
void RefreshModTree(TreeView treeView, string[] modList)