Return to Snippet

Revision: 4748
at January 19, 2008 00:25 by sudarkoff


Initial Code
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;
}

Initial URL
http://briksoftware.com/blog/?p=70

Initial Description
Instead of installing the real tools I install 2 trampoline applications in /usr/bin called respectively pdflock and pdfunlock. The trampoline then uses NSWorkspace to locate the bundle, and starts the real executable found in the application’s bundle.

Initial Title
Installing things to /usr/bin - Trampolines

Initial Tags


Initial Language
Objective C