From dea652d9a2a02a23fd1fe17eaf6c81c12419ab4f Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Fri, 9 Feb 2024 08:27:36 +0200 Subject: [PATCH] [macOS] Allow `open_shell` to handle filenames without `file://`. (cherry picked from commit cc313a1c1c7fb5cffd46cd9c8a2125770b12dc5a) --- platform/macos/os_macos.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platform/macos/os_macos.mm b/platform/macos/os_macos.mm index 29dff683d53..5bfa1ed4602 100644 --- a/platform/macos/os_macos.mm +++ b/platform/macos/os_macos.mm @@ -354,8 +354,11 @@ Error OS_MacOS::shell_show_in_file_manager(String p_path, bool p_open_folder) { Error OS_MacOS::shell_open(String p_uri) { NSString *string = [NSString stringWithUTF8String:p_uri.utf8().get_data()]; NSURL *uri = [[NSURL alloc] initWithString:string]; - // Escape special characters in filenames if (!uri || !uri.scheme || [uri.scheme isEqual:@"file"]) { + // No scheme set, assume "file://" and escape special characters. + if (!p_uri.begins_with("file://")) { + string = [NSString stringWithUTF8String:("file://" + p_uri).utf8().get_data()]; + } uri = [[NSURL alloc] initWithString:[string stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]]; } [[NSWorkspace sharedWorkspace] openURL:uri];