Created
December 8, 2008 18:19
-
-
Save mkhl/33545 to your computer and use it in GitHub Desktop.
CLI tool that trampolines to a tool in the associated app bundle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from: somewhere around http://briksoftware.com/blog/ | |
int main(int argc, char *argv[]) | |
{ | |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
NSWorkspace *env = [NSWorkspace sharedWorkspace]; | |
NSString *app = [env absolutePathForAppBundleWithIdentifier:@"com.pdfkey.pdfkeypro"]; | |
NSString *targetPath = [[app stringByAppendingPathComponent:@"Contents/Resources/pdflock"] retain]; | |
const char *CStringPath = [targetPath UTF8String]; | |
[pool release]; | |
execv(CStringPath, argv); | |
// You reach this code only if execv returns, which means that something wrong happened. | |
[targetPath release]; | |
printf("PDFKey Pro is not installed. Please download it from http://pdfkey.com\n"); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment