SDL_OpenURL (macOS): try to open path if the url cannot be opened (#4830)

* SDL_OpenURL (macOS): try to open path if the url cannot be opened

* SDL_OpenURL (macOS): use CFURLCreateWithBytes & LSOpenCFURLRef to correctly escape input

* fix type casting + indentation
This commit is contained in:
superzazu 2021-11-03 16:35:24 +01:00 committed by GitHub
parent e2ba84a532
commit 839ca0ea64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -27,10 +27,10 @@ int
SDL_SYS_OpenURL(const char *url) SDL_SYS_OpenURL(const char *url)
{ @autoreleasepool { @autoreleasepool
{ {
NSString *nsstr = [NSString stringWithUTF8String:url]; CFURLRef cfurl = CFURLCreateWithBytes(NULL, (const UInt8 *) url, SDL_strlen(url), kCFStringEncodingUTF8, NULL);
NSURL *nsurl = [NSURL URLWithString:nsstr]; OSStatus status = LSOpenCFURLRef(cfurl, NULL);
return [[NSWorkspace sharedWorkspace] openURL:nsurl] ? 0 : -1; CFRelease(cfurl);
return status == noErr ? 0 : -1;
}} }}
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */