Installing from CD: Volume names / mount points are unreliable identifiers - check for specific files on the disk instead.
This commit is contained in:
@@ -28,13 +28,13 @@ namespace OpenRA.FileFormats
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetMountedDisk(string[] volumeNames)
|
||||
public static string GetMountedDisk(Func<string, bool> isValidDisk)
|
||||
{
|
||||
var volumes = DriveInfo.GetDrives()
|
||||
.Where(v => v.DriveType == DriveType.CDRom && v.IsReady)
|
||||
.Select(v => v.RootDirectory.FullName);
|
||||
|
||||
return volumes.FirstOrDefault(v => volumeNames.Contains(Path.GetFileName(v)));
|
||||
return volumes.FirstOrDefault(v => isValidDisk(v));
|
||||
}
|
||||
|
||||
// TODO: The package should be mounted into its own context to avoid name collisions with installed files
|
||||
|
||||
@@ -49,7 +49,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
|
||||
void CheckForDisk()
|
||||
{
|
||||
var path = InstallUtils.GetMountedDisk(new [] { "GDI95", "NOD95" });
|
||||
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);
|
||||
|
||||
if (path != null)
|
||||
Install(path);
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
var installButton = panel.GetWidget<ButtonWidget>("INSTALL_BUTTON");
|
||||
installButton.OnClick = () =>
|
||||
Widget.OpenWindow("INSTALL_MUSIC_PANEL", new WidgetArgs() {{ "afterInstall", afterInstall }});
|
||||
installButton.IsVisible = () => music.Length < 2; // Hack around ra shipping (only) hellmarch by default
|
||||
installButton.IsVisible = () => music.Length < 3; // Hack around music being split between transit.mix and scores.mix
|
||||
|
||||
panel.GetWidget("NO_MUSIC_LABEL").IsVisible = noMusic;
|
||||
|
||||
@@ -216,7 +216,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
|
||||
void CheckForDisk()
|
||||
{
|
||||
var path = InstallUtils.GetMountedDisk(new [] { "GDI95", "NOD95" });
|
||||
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);
|
||||
|
||||
if (path != null)
|
||||
Install(path);
|
||||
|
||||
@@ -49,7 +49,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
|
||||
void CheckForDisk()
|
||||
{
|
||||
var path = InstallUtils.GetMountedDisk(new [] { "CD1", "CD2" });
|
||||
Func<string, bool> ValidDiskFilter = diskRoot => File.Exists(diskRoot+Path.DirectorySeparatorChar+"MAIN.MIX") &&
|
||||
File.Exists(new string[] { diskRoot, "INSTALL", "REDALERT.MIX" }.Aggregate(Path.Combine));
|
||||
|
||||
var path = InstallUtils.GetMountedDisk(ValidDiskFilter);
|
||||
|
||||
if (path != null)
|
||||
Install(path);
|
||||
|
||||
Reference in New Issue
Block a user