diff --git a/src/BizHawk.Client.Common/RomLoader.cs b/src/BizHawk.Client.Common/RomLoader.cs index 7f75937902..eaf8a3e280 100644 --- a/src/BizHawk.Client.Common/RomLoader.cs +++ b/src/BizHawk.Client.Common/RomLoader.cs @@ -202,7 +202,7 @@ namespace BizHawk.Client.Common private List DiscsFromXml(XmlGame xmlGame, string systemId, DiscType diskType) { var discs = new List(); - foreach (var e in xmlGame.AssetFullPaths.Where(a => IsDisc(Path.GetExtension(a)))) + foreach (var e in xmlGame.AssetFullPaths.Where(a => Disc.IsValidExtension(Path.GetExtension(a)))) { var disc = diskType.Create(e, str => { DoLoadErrorCallback(str, systemId, LoadErrorType.DiscError); }); if (disc != null) @@ -417,7 +417,7 @@ namespace BizHawk.Client.Common System = "PSX" }; } - else if (IsDisc(ext)) + else if (Disc.IsValidExtension(ext)) { if (file.IsArchive) { @@ -768,7 +768,8 @@ namespace BizHawk.Client.Common break; case "GEN": var genDiscs = DiscsFromXml(xmlGame, "GEN", DiscType.MegaCD); - var romBytes = xmlGame.Assets.Where(a => !IsDisc(a.Key)) + var romBytes = xmlGame.Assets + .Where(a => !Disc.IsValidExtension(a.Key)) .Select(a => a.Value) .FirstOrDefault(); if (!genDiscs.Any() && romBytes == null) @@ -1107,11 +1108,5 @@ namespace BizHawk.Client.Common Game = game; return true; } - - private static bool IsDisc(string extension) => - extension == ".iso" - || extension == ".cue" - || extension == ".ccd" - || extension == ".mds"; } } diff --git a/src/BizHawk.Emulation.DiscSystem/Disc.cs b/src/BizHawk.Emulation.DiscSystem/Disc.cs index ecbbb9e1cf..d7af67ddf8 100644 --- a/src/BizHawk.Emulation.DiscSystem/Disc.cs +++ b/src/BizHawk.Emulation.DiscSystem/Disc.cs @@ -129,5 +129,10 @@ namespace BizHawk.Emulation.DiscSystem internal Disc() {} + public static bool IsValidExtension(string extension) => + extension == ".iso" + || extension == ".cue" + || extension == ".ccd" + || extension == ".mds"; } } \ No newline at end of file diff --git a/src/BizHawk.Emulation.DiscSystem/DiscExtensions.cs b/src/BizHawk.Emulation.DiscSystem/DiscExtensions.cs index 41996ea073..b6a48b3789 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscExtensions.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscExtensions.cs @@ -4,15 +4,15 @@ namespace BizHawk.Emulation.DiscSystem { public static class DiscExtensions { - public static Disc Create(this DiscType diskType, string discPath, Action errorCallback) + public static Disc Create(this DiscType type, string path, Action errorCallback) { //--- load the disc in a context which will let us abort if it's going to take too long - var discMountJob = new DiscMountJob { IN_FromPath = discPath, IN_SlowLoadAbortThreshold = 8 }; + var discMountJob = new DiscMountJob { IN_FromPath = path, IN_SlowLoadAbortThreshold = 8 }; discMountJob.Run(); var disc = discMountJob.OUT_Disc; if (disc == null) { - throw new InvalidOperationException($"Can't find the file specified: {discPath}"); + throw new InvalidOperationException($"Can't find the file specified: {path}"); } if (discMountJob.OUT_SlowLoadAborted) @@ -28,9 +28,9 @@ namespace BizHawk.Emulation.DiscSystem var discType = new DiscIdentifier(disc).DetectDiscType(); - if (discType != diskType) + if (discType != type) { - errorCallback($"Not a {diskType} disc"); + errorCallback($"Not a {type} disc"); return null; }