Index: NSWorkspace.m =================================================================== --- NSWorkspace.m (revision 34041) +++ NSWorkspace.m (working copy) @@ -820,8 +820,30 @@ if ([self _extension: ext role: nil app: &appName] == NO) { - NSWarnLog(@"No known applications for file extension '%@'", ext); - return NO; + #ifdef __MINGW32__ + unichar *buffer = (unichar *)calloc(1, ([fullPath length]+1) * sizeof(unichar)); + [fullPath getCharacters:buffer range:NSMakeRange(0, [fullPath length])]; + BOOL success = (ShellExecuteW(GetDesktopWindow(), L"open", buffer, NULL, NULL, SW_SHOWNORMAL) > 32); + free(buffer); + if (!success) + NSWarnLog(@"No known applications for file extension '%@'", ext); + return success; + #else + BOOL success = FALSE; + NSTask * task = [NSTask launchedTaskWithLaunchPath: [NSTask launchPathForTool:@"xdg-open"] + arguments: [NSArray arrayWithObject: [fullPath fileSystemRepresentation]]]; + if (task != nil) + { + [task waitUntilExit]; + if ([task terminationStatus] == 0) + success = YES; + } + + + if (!success) + NSWarnLog(@"No known applications for file extension '%@' xdg-open result %i", ext, [task terminationStatus]); + return success; + #endif } } @@ -949,6 +971,32 @@ return YES; } } + + #ifdef __MINGW32__ /* try native (ShellExecuteW) next */ + + unichar *buffer = (unichar *)calloc(1, ([[url absoluteString] length]+1) * sizeof(unichar)); + [[url absoluteString] getCharacters:buffer range:NSMakeRange(0, [[url absoluteString] length])]; + BOOL success = (ShellExecuteW(GetDesktopWindow(), L"open", buffer, NULL, NULL, SW_SHOWNORMAL) > 32); + free(buffer); + if (success) + return YES; + + #else /* try native (freedesktop) next */ + NSTask * task = [NSTask launchedTaskWithLaunchPath: [NSTask launchPathForTool:@"xdg-open"] + arguments: [NSArray arrayWithObject: [url absoluteString]]]; + if (task != nil) + { + [task waitUntilExit]; + if ([task terminationStatus] == 0) + return YES; + else + return NO + } + else + return NO + #endif + + /* No application found to open the URL. * Try any OpenURL service available. */