Release/Growl/OpenDocWithoutAddingToRecents/OpenDocWithoutAddingToRecents.m
changeset 4451 939a07eddf5e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Release/Growl/OpenDocWithoutAddingToRecents/OpenDocWithoutAddingToRecents.m	Sun Sep 27 23:40:15 2009 -0700
     1.3 @@ -0,0 +1,30 @@
     1.4 +int main (int argc, char **argv) {
     1.5 +	int status = EXIT_SUCCESS;
     1.6 +
     1.7 +    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1.8 +
     1.9 +	if (argv[1] == NULL) {
    1.10 +		NSLog(@"%s invoked with no arguments", argv[0]);
    1.11 +		status = EXIT_FAILURE;
    1.12 +		goto end;
    1.13 +	}
    1.14 +	NSString *appPath = [NSString stringWithUTF8String:argv[1]];
    1.15 +
    1.16 +	struct LSLaunchURLSpec URLSpec = {
    1.17 +		.appURL = NULL,
    1.18 +		.itemURLs = (CFArrayRef)[NSArray arrayWithObject:[NSURL fileURLWithPath:appPath]],
    1.19 +		.passThruParams = NULL,
    1.20 +		.launchFlags = kLSLaunchNoParams | kLSLaunchDontAddToRecents | kLSLaunchDontSwitch | kLSLaunchAndDisplayErrors,
    1.21 +		.asyncRefCon = NULL, //Because we're doing it synchronously.
    1.22 +	};
    1.23 +	OSStatus err = LSOpenFromURLSpec(&URLSpec, NULL);
    1.24 +	if (err != noErr) {
    1.25 +		NSLog(@"Couldn't launch %@: LSOpenFromURLSpec returned %i/%s", appPath, err, GetMacOSStatusCommentString(err));
    1.26 +		status = EXIT_FAILURE;
    1.27 +		goto end;
    1.28 +	}
    1.29 +
    1.30 +end:
    1.31 +    [pool drain];
    1.32 +    return status;
    1.33 +}