#include "GUIDialogs.h" #import namespace GUIDialogs { char* ChooseFile() { NSWindow *keyWindow = [NSApp keyWindow]; char* path = nullptr; NSOpenPanel *panel = [NSOpenPanel openPanel]; [panel setCanChooseFiles:YES]; [panel setCanChooseDirectories:NO]; [panel setAllowsMultipleSelection:NO]; NSInteger clicked = [panel runModal]; if (clicked == NSFileHandlingPanelOKButton) { for (NSURL *url in [panel URLs]) { path = strdup([url fileSystemRepresentation]); //const char* urlPath = [url fileSystemRepresentation]; //path = (char*)malloc(strlen(urlPath)); //strcpy(path, urlPath); } } [keyWindow makeKeyWindow]; return path; } }