unify disk check between music install and game install for cnc

This commit is contained in:
Chris Forbes
2011-10-06 23:43:32 +13:00
parent 281f706b02
commit e9a4ec5403
2 changed files with 13 additions and 10 deletions

View File

@@ -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<string, bool> 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);