diff --git a/src/BizHawk.Client.EmuHawk/EmuHawkUtil.cs b/src/BizHawk.Client.EmuHawk/EmuHawkUtil.cs index c203977a42..7cf66ffed7 100644 --- a/src/BizHawk.Client.EmuHawk/EmuHawkUtil.cs +++ b/src/BizHawk.Client.EmuHawk/EmuHawkUtil.cs @@ -3,7 +3,6 @@ using System.IO; using System.Security.Principal; using BizHawk.Common; -using BizHawk.Common.StringExtensions; namespace BizHawk.Client.EmuHawk { @@ -16,7 +15,7 @@ namespace BizHawk.Client.EmuHawk /// http://stackoverflow.com/questions/139010/how-to-resolve-a-lnk-in-c-sharp public static string ResolveShortcut(string filename) { - if (OSTailoredCode.IsUnixHost || filename.ContainsOrdinal('|') + if (OSTailoredCode.IsUnixHost || HawkFile.PathContainsPipe(filename) || !".lnk".Equals(Path.GetExtension(filename), StringComparison.OrdinalIgnoreCase)) { return filename; // archive internal files are never shortcuts (and choke when analyzing any further) diff --git a/src/BizHawk.Client.EmuHawk/RetroAchievements/RCheevos.Debug.cs b/src/BizHawk.Client.EmuHawk/RetroAchievements/RCheevos.Debug.cs index 330339a622..3726db6495 100644 --- a/src/BizHawk.Client.EmuHawk/RetroAchievements/RCheevos.Debug.cs +++ b/src/BizHawk.Client.EmuHawk/RetroAchievements/RCheevos.Debug.cs @@ -8,7 +8,6 @@ using System.Windows.Forms; using BizHawk.Client.Common; using BizHawk.Common; using BizHawk.Common.PathExtensions; -using BizHawk.Common.StringExtensions; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Arcades.MAME; using BizHawk.Emulation.DiscSystem; @@ -311,7 +310,7 @@ namespace BizHawk.Client.EmuHawk { static string ResolvePath(string path) { - if (!path.ContainsOrdinal('|') && Disc.IsValidExtension(Path.GetExtension(path))) + if (!HawkFile.PathContainsPipe(path) && Disc.IsValidExtension(Path.GetExtension(path))) { return path; // nothing to do in this case } @@ -343,7 +342,7 @@ namespace BizHawk.Client.EmuHawk static ConsoleID IdentifyConsole(string path) { - if (!path.ContainsOrdinal('|') && Disc.IsValidExtension(Path.GetExtension(path))) + if (!HawkFile.PathContainsPipe(path) && Disc.IsValidExtension(Path.GetExtension(path))) { using var disc = DiscExtensions.CreateAnyType(path, Console.WriteLine); if (disc is null) diff --git a/src/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs b/src/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs index 5e943793c8..dab4325135 100644 --- a/src/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs +++ b/src/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.cs @@ -61,7 +61,7 @@ namespace BizHawk.Client.EmuHawk if (!Game.IsNullInstance()) { - if (MainForm.CurrentlyOpenRom.ContainsOrdinal('|')) + if (HawkFile.PathContainsPipe(MainForm.CurrentlyOpenRom)) { var pieces = MainForm.CurrentlyOpenRom.Split('|'); diff --git a/src/BizHawk.Common/HawkFile/HawkFile.cs b/src/BizHawk.Common/HawkFile/HawkFile.cs index fffdeed224..f096d331a0 100644 --- a/src/BizHawk.Common/HawkFile/HawkFile.cs +++ b/src/BizHawk.Common/HawkFile/HawkFile.cs @@ -2,8 +2,10 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Runtime.CompilerServices; using BizHawk.Common.CollectionExtensions; +using BizHawk.Common.StringExtensions; namespace BizHawk.Common { @@ -21,6 +23,10 @@ namespace BizHawk.Common /// public sealed class HawkFile : IDisposable { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static bool PathContainsPipe(string s) + => s.ContainsOrdinal('|'); + private readonly List? _archiveItems; private Stream? _boundStream; diff --git a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAMEMachineDB.cs b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAMEMachineDB.cs index 55c9946605..94f064d08f 100644 --- a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAMEMachineDB.cs +++ b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAMEMachineDB.cs @@ -5,7 +5,6 @@ using System.IO; using System.Threading; using BizHawk.Common; -using BizHawk.Common.StringExtensions; namespace BizHawk.Emulation.Cores.Arcades.MAME { @@ -54,7 +53,7 @@ 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.ContainsOrdinal('|')) return false; // binded archive, can't be a mame zip (note | is not a legal filesystem char, at least on windows) + if (HawkFile.PathContainsPipe(path)) 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()); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/3DS/Encore.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/3DS/Encore.cs index fa3d892f2e..4846c5a719 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/3DS/Encore.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/3DS/Encore.cs @@ -7,7 +7,6 @@ using System.Text; using BizHawk.BizInvoke; using BizHawk.Common; -using BizHawk.Common.StringExtensions; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Consoles.Nintendo.N3DS @@ -47,7 +46,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.N3DS [CoreConstructor(VSystemID.Raw.N3DS)] public Encore(CoreLoadParameters lp) { - if (lp.Roms.Exists(static r => r.RomPath.ContainsOrdinal('|'))) + if (lp.Roms.Exists(static r => HawkFile.PathContainsPipe(r.RomPath))) { throw new InvalidOperationException("3DS does not support compressed ROMs"); }