private void LoadM3U(string path, CoreComm nextComm, HawkFile file, string forcedCoreName, out IEmulator nextEmulator, out GameInfo game) { M3U_File m3u; using (var sr = new StreamReader(path)) m3u = M3U_File.Read(sr); if (m3u.Entries.Count == 0) { throw new InvalidOperationException("Can't load an empty M3U"); } m3u.Rebase(Path.GetDirectoryName(path)); var discs = m3u.Entries .Select(e => e.Path) .Where(p => Disc.IsValidExtension(Path.GetExtension(p))) .Select(path => new { d = DiscExtensions.CreateAnyType(path, str => DoLoadErrorCallback(str, "???", LoadErrorType.DiscError)), p = path, }) .Where(a => a.d != null) .Select(a => (IDiscAsset) new DiscAsset { DiscData = a.d, DiscType = new DiscIdentifier(a.d).DetectDiscType(), DiscName = Path.GetFileNameWithoutExtension(a.p) }) .ToList(); if (m3u.Entries.Count == 0) { throw new InvalidOperationException("Couldn't load any contents of the M3U as discs"); } game = MakeGameFromDisc(discs[0].DiscData, Path.GetExtension(m3u.Entries[0].Path), discs[0].DiscName); var cip = new CoreInventoryParameters(this) { Comm = nextComm, Game = game, Discs = discs }; nextEmulator = MakeCoreFromCoreInventory(cip, forcedCoreName); }