mirror of
https://github.com/godotengine/godot.git
synced 2025-02-23 23:15:07 +08:00
[macOS] Allow open_shell
to handle filenames without file://
.
This commit is contained in:
parent
41564aaf77
commit
cc313a1c1c
@ -356,8 +356,11 @@ Error OS_MacOS::shell_show_in_file_manager(String p_path, bool p_open_folder) {
|
|||||||
Error OS_MacOS::shell_open(String p_uri) {
|
Error OS_MacOS::shell_open(String p_uri) {
|
||||||
NSString *string = [NSString stringWithUTF8String:p_uri.utf8().get_data()];
|
NSString *string = [NSString stringWithUTF8String:p_uri.utf8().get_data()];
|
||||||
NSURL *uri = [[NSURL alloc] initWithString:string];
|
NSURL *uri = [[NSURL alloc] initWithString:string];
|
||||||
// Escape special characters in filenames
|
|
||||||
if (!uri || !uri.scheme || [uri.scheme isEqual:@"file"]) {
|
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]]];
|
uri = [[NSURL alloc] initWithString:[string stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]];
|
||||||
}
|
}
|
||||||
[[NSWorkspace sharedWorkspace] openURL:uri];
|
[[NSWorkspace sharedWorkspace] openURL:uri];
|
||||||
|
Loading…
Reference in New Issue
Block a user