Release/Growl/OpenDocWithoutAddingToRecents/OpenDocWithoutAddingToRecents.m
author Peter Hosey <hg@boredzo.org>
Sun Sep 27 23:40:15 2009 -0700 (2009-09-27)
changeset 4451 939a07eddf5e
permissions -rw-r--r--
Replacing OpenGrowlPrefPane with a modified version of OpenAppWithoutAddingToRecents that uses Launch Services.
     1 int main (int argc, char **argv) {
     2 	int status = EXIT_SUCCESS;
     3 
     4     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     5 
     6 	if (argv[1] == NULL) {
     7 		NSLog(@"%s invoked with no arguments", argv[0]);
     8 		status = EXIT_FAILURE;
     9 		goto end;
    10 	}
    11 	NSString *appPath = [NSString stringWithUTF8String:argv[1]];
    12 
    13 	struct LSLaunchURLSpec URLSpec = {
    14 		.appURL = NULL,
    15 		.itemURLs = (CFArrayRef)[NSArray arrayWithObject:[NSURL fileURLWithPath:appPath]],
    16 		.passThruParams = NULL,
    17 		.launchFlags = kLSLaunchNoParams | kLSLaunchDontAddToRecents | kLSLaunchDontSwitch | kLSLaunchAndDisplayErrors,
    18 		.asyncRefCon = NULL, //Because we're doing it synchronously.
    19 	};
    20 	OSStatus err = LSOpenFromURLSpec(&URLSpec, NULL);
    21 	if (err != noErr) {
    22 		NSLog(@"Couldn't launch %@: LSOpenFromURLSpec returned %i/%s", appPath, err, GetMacOSStatusCommentString(err));
    23 		status = EXIT_FAILURE;
    24 		goto end;
    25 	}
    26 
    27 end:
    28     [pool drain];
    29     return status;
    30 }