From d0266816a550228b05dc972868bf5d4e43bf96dd Mon Sep 17 00:00:00 2001 From: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com> Date: Wed, 16 Nov 2022 17:32:20 -0800 Subject: [PATCH] Fix #3448. Support MAME 7z romsets --- src/BizHawk.Client.Common/RomLoader.cs | 2 +- src/BizHawk.Emulation.Common/Database/Database.cs | 1 + src/BizHawk.Emulation.Cores/Arcades/MAME/MAMEMachineDB.cs | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/BizHawk.Client.Common/RomLoader.cs b/src/BizHawk.Client.Common/RomLoader.cs index cf8362764c..8d720fce0c 100644 --- a/src/BizHawk.Client.Common/RomLoader.cs +++ b/src/BizHawk.Client.Common/RomLoader.cs @@ -780,7 +780,7 @@ namespace BizHawk.Client.Common public static readonly IReadOnlyCollection AppleII = new[] { "dsk", "do", "po" }; - public static readonly IReadOnlyCollection Arcade = new[] { "zip", "chd" }; + public static readonly IReadOnlyCollection Arcade = new[] { "zip", "7z", "chd" }; public static readonly IReadOnlyCollection C64 = new[] { "prg", "d64", "g64", "crt", "tap" }; diff --git a/src/BizHawk.Emulation.Common/Database/Database.cs b/src/BizHawk.Emulation.Common/Database/Database.cs index 450500b187..5a800724b1 100644 --- a/src/BizHawk.Emulation.Common/Database/Database.cs +++ b/src/BizHawk.Emulation.Common/Database/Database.cs @@ -404,6 +404,7 @@ namespace BizHawk.Emulation.Common break; case ".ZIP": + case ".7Z": game.System = VSystemID.Raw.Arcade; break; } diff --git a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAMEMachineDB.cs b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAMEMachineDB.cs index 4f392748ad..dae31e314d 100644 --- a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAMEMachineDB.cs +++ b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAMEMachineDB.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Linq; using System.Threading; using BizHawk.Common; @@ -35,7 +36,7 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME private MAMEMachineDB(string basePath) { - using HawkFile mameMachineFile = new(Path.Combine(basePath, "mame_machines.txt")); + using var mameMachineFile = new HawkFile(Path.Combine(basePath, "mame_machines.txt")); using var sr = new StreamReader(mameMachineFile.GetStream()); while (true) { @@ -53,7 +54,8 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME public static bool IsMAMEMachine(string path) { if (_acquire == null) throw new InvalidOperationException("MAME Machine DB not initialized. It's a client responsibility because only a client knows where the database is located."); - if (Path.GetExtension(path).ToLowerInvariant() != ".zip") return false; + if (path.Contains('|')) return false; // binded archive, can't be a mame zip (note | is not a legal filesystem char, at least on windows) + if (Path.GetExtension(path).ToLowerInvariant() is not ".zip" and not ".7z") return false; _acquire.WaitOne(); return Instance.MachineDB.Contains(Path.GetFileNameWithoutExtension(path).ToLowerInvariant()); }