From e9a4ec54035bfb6618f937e37f2225214f28d4c7 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Thu, 6 Oct 2011 23:43:32 +1300 Subject: [PATCH] unify disk check between music install and game install for cnc --- .../Widgets/Logic/CncInstallFromCDLogic.cs | 17 ++++++++++++----- .../Widgets/Logic/CncMusicPlayerLogic.cs | 6 +----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallFromCDLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallFromCDLogic.cs index b2428e96b0..0c599ba566 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallFromCDLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallFromCDLogic.cs @@ -46,13 +46,20 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic CheckForDisk(); } + public static bool IsValidDisk(string diskRoot) + { + var files = new string[][] { + new [] { diskRoot, "CONQUER.MIX" }, + new [] { diskRoot, "DESERT.MIX" }, + new [] { diskRoot, "INSTALL", "SETUP.Z" }, + }; + + return files.All(f => File.Exists(f.Aggregate(Path.Combine))); + } + void CheckForDisk() { - Func ValidDiskFilter = diskRoot => File.Exists(diskRoot+Path.DirectorySeparatorChar+"CONQUER.MIX") && - File.Exists(diskRoot+Path.DirectorySeparatorChar+"DESERT.MIX") && - File.Exists(new string[] { diskRoot, "INSTALL", "SETUP.Z" }.Aggregate(Path.Combine)); - - var path = InstallUtils.GetMountedDisk(ValidDiskFilter); + var path = InstallUtils.GetMountedDisk(IsValidDisk); if (path != null) Install(path); diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncMusicPlayerLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncMusicPlayerLogic.cs index fc091a59ac..60f072aaaf 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncMusicPlayerLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncMusicPlayerLogic.cs @@ -215,11 +215,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic void CheckForDisk() { - Func ValidDiskFilter = diskRoot => File.Exists(diskRoot+Path.DirectorySeparatorChar+"CONQUER.MIX") && - File.Exists(diskRoot+Path.DirectorySeparatorChar+"DESERT.MIX") && - File.Exists(new string[] { diskRoot, "INSTALL", "SETUP.Z" }.Aggregate(Path.Combine)); - - var path = InstallUtils.GetMountedDisk(ValidDiskFilter); + var path = InstallUtils.GetMountedDisk(CncInstallFromCDLogic.IsValidDisk); if (path != null) Install(path);