From 077097c112de4f9d307230311a68c6e9cd60d091 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 10 Mar 2021 21:55:00 +0530 Subject: [PATCH] Also implement openFiles --- glfw/cocoa_init.m | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/glfw/cocoa_init.m b/glfw/cocoa_init.m index 8df4a64e6..caee9ea8d 100644 --- a/glfw/cocoa_init.m +++ b/glfw/cocoa_init.m @@ -360,6 +360,21 @@ static GLFWapplicationwillfinishlaunchingfun finish_launching_callback = NULL; return _glfw.ns.file_open_callback(path); } +- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames { + (void)sender; + if (!_glfw.ns.file_open_callback || !filenames) return; + for (id x in filenames) { + NSString *filename = x; + const char *path = NULL; + @try { + path = [[NSFileManager defaultManager] fileSystemRepresentationWithPath: filename]; + } @catch(NSException *exc) { + NSLog(@"Converting openFiles filename: %@ failed with error: %@", filename, exc.reason); + } + if (path) _glfw.ns.file_open_callback(path); + } +} + - (void)applicationDidFinishLaunching:(NSNotification *)notification { (void)notification;