|
hg@4451
|
1 |
int main (int argc, char **argv) {
|
|
hg@4451
|
2 |
int status = EXIT_SUCCESS;
|
|
hg@4451
|
3 |
|
|
hg@4451
|
4 |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
hg@4451
|
5 |
|
|
hg@4451
|
6 |
if (argv[1] == NULL) {
|
|
hg@4451
|
7 |
NSLog(@"%s invoked with no arguments", argv[0]);
|
|
hg@4451
|
8 |
status = EXIT_FAILURE;
|
|
hg@4451
|
9 |
goto end;
|
|
hg@4451
|
10 |
}
|
|
hg@4451
|
11 |
NSString *appPath = [NSString stringWithUTF8String:argv[1]];
|
|
hg@4451
|
12 |
|
|
hg@4451
|
13 |
struct LSLaunchURLSpec URLSpec = {
|
|
hg@4451
|
14 |
.appURL = NULL,
|
|
hg@4451
|
15 |
.itemURLs = (CFArrayRef)[NSArray arrayWithObject:[NSURL fileURLWithPath:appPath]],
|
|
hg@4451
|
16 |
.passThruParams = NULL,
|
|
hg@4451
|
17 |
.launchFlags = kLSLaunchNoParams | kLSLaunchDontAddToRecents | kLSLaunchDontSwitch | kLSLaunchAndDisplayErrors,
|
|
hg@4451
|
18 |
.asyncRefCon = NULL, //Because we're doing it synchronously.
|
|
hg@4451
|
19 |
};
|
|
hg@4451
|
20 |
OSStatus err = LSOpenFromURLSpec(&URLSpec, NULL);
|
|
hg@4451
|
21 |
if (err != noErr) {
|
|
hg@4451
|
22 |
NSLog(@"Couldn't launch %@: LSOpenFromURLSpec returned %i/%s", appPath, err, GetMacOSStatusCommentString(err));
|
|
hg@4451
|
23 |
status = EXIT_FAILURE;
|
|
hg@4451
|
24 |
goto end;
|
|
hg@4451
|
25 |
}
|
|
hg@4451
|
26 |
|
|
hg@4451
|
27 |
end:
|
|
hg@4451
|
28 |
[pool drain];
|
|
hg@4451
|
29 |
return status;
|
|
hg@4451
|
30 |
}
|