diff --git a/ChangeLog b/ChangeLog index aa37dda7a..6e47f4fbc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,12 @@ +2009-03-20 Richard Frith-Macdonald + + * Tools/gopen.m: Extend to open URLs as well as files. + 2009-03-20 Fred Kiefer * Source/NSOutlineView.m (-drawRow:clipRect:): Changed order of - expresions in condition to avoid possible access to uninitialized memory. + expresions in condition to avoid possible access to uninitialized + memory. * Source/NSScrollView.m (-initWithCoder:): Don't set _hasCornerView. 2009-03-18 Richard Frith-Macdonald diff --git a/Tools/gopen.m b/Tools/gopen.m index 26863b420..5c331c0b4 100644 --- a/Tools/gopen.m +++ b/Tools/gopen.m @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -66,6 +67,9 @@ main(int argc, char** argv, char **env_c) NSString *filetoopen = nil; NSString *filetoprint = nil; NSString *nxhost = nil; + BOOL isDir; + BOOL exists; + NSURL *u; #ifdef GS_PASS_ARGUMENTS [NSProcessInfo initializeWithArguments:argv count:argc environment:env_c]; @@ -96,9 +100,21 @@ main(int argc, char** argv, char **env_c) if (filetoopen) { - filetoopen = absolutePath(fm, filetoopen); - [workspace openFile: filetoopen - withApplication: application]; + exists = [fm fileExistsAtPath: arg isDirectory: &isDir]; + if (exists == NO) + { + if ([filetoopen hasPrefix: @"/"] == NO + && (u = [NSURL URLWithString: filetoopen]) != nil) + { + [workspace openURL: u]; + } + } + else + { + filetoopen = absolutePath(fm, filetoopen); + [workspace openFile: filetoopen + withApplication: application]; + } } if (filetoprint) @@ -144,38 +160,41 @@ main(int argc, char** argv, char **env_c) { NS_DURING { - BOOL isDir = NO, exists = NO; - exists = [fm fileExistsAtPath: arg isDirectory: &isDir]; if (exists == YES) { arg = absolutePath(fm, arg); - } - if (exists && !isDir && [fm isExecutableFileAtPath: arg]) - { - [workspace openFile: arg withApplication: terminal]; - } - else // no argument specified - { - // First check to see if it's an application - if ([ext isEqualToString: @"app"] - || [ext isEqualToString: @"debug"] - || [ext isEqualToString: @"profile"]) + if (isDir == NO && [fm isExecutableFileAtPath: arg]) { - [workspace launchApplication: arg]; + [workspace openFile: arg withApplication: terminal]; } - else + else // no argument specified { - if (![workspace openFile: arg - withApplication: application]) + // First check to see if it's an application + if ([ext isEqualToString: @"app"] + || [ext isEqualToString: @"debug"] + || [ext isEqualToString: @"profile"]) { - // no recognized extension, - // run application indicated by environment var. - NSLog(@"Opening %@ with %@",arg,editor); - [workspace openFile: arg withApplication: editor]; + [workspace launchApplication: arg]; + } + else + { + if (![workspace openFile: arg + withApplication: application]) + { + // no recognized extension, + // run application indicated by environment var. + NSLog(@"Opening %@ with %@",arg,editor); + [workspace openFile: arg withApplication: editor]; + } } } } + else if ([arg hasPrefix: @"/"] == NO + && (u = [NSURL URLWithString: arg]) != nil) + { + [workspace openURL: u]; + } } NS_HANDLER {