diff --git a/osu.Framework/Platform/MacOS/MacOSGameHost.cs b/osu.Framework/Platform/MacOS/MacOSGameHost.cs index 9019c7cdf6..67100d46b3 100644 --- a/osu.Framework/Platform/MacOS/MacOSGameHost.cs +++ b/osu.Framework/Platform/MacOS/MacOSGameHost.cs @@ -7,11 +7,11 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using osu.Framework.Extensions; using osu.Framework.Input; using osu.Framework.Input.Bindings; using osu.Framework.Input.Handlers; using osu.Framework.Input.Handlers.Mouse; +using osu.Framework.Logging; using osu.Framework.Platform.MacOS.Native; namespace osu.Framework.Platform.MacOS @@ -53,6 +53,29 @@ protected override void Swap() Renderer.WaitUntilIdle(); } + public override bool PresentFileExternally(string filename) + { + string folderPath = Path.GetDirectoryName(filename); + + if (folderPath == null) + { + Logger.Log($"Failed to get directory for {filename}", level: LogLevel.Debug); + return false; + } + + if (!File.Exists(filename) && !Directory.Exists(filename)) + { + Logger.Log($"Cannot find file for '{filename}'", level: LogLevel.Debug); + + // Open the folder without the file selected if we can't find the file + OpenFileExternally(folderPath); + return true; + } + + Finder.OpenFolderAndSelectItem(filename); + return true; + } + protected override IEnumerable CreateAvailableInputHandlers() { var handlers = base.CreateAvailableInputHandlers(); @@ -67,11 +90,6 @@ protected override IEnumerable CreateAvailableInputHandlers() return handlers; } - public override bool PresentFileExternally(string filename) - { - return Finder.OpenFolderAndSelectItem(filename.TrimDirectorySeparator()); - } - public override IEnumerable PlatformKeyBindings => KeyBindings; ///