Posted By

sudarkoff on 01/19/08



Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Installing things to /usr/bin - Trampolines

 / Published in: Objective C


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.

  1. int main(int argc, char *argv[])
  2. {
  3. NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  4. NSWorkspace *env = [NSWorkspace sharedWorkspace];
  5. NSString *app = [env absolutePathForAppBundleWithIdentifier:@"com.pdfkey.pdfkeypro"];
  6. NSString *targetPath = [[app stringByAppendingPathComponent:@"Contents/Resources/pdflock"] retain];
  8. const char *CStringPath = [targetPath UTF8String];
  9. [pool release];
  11. execv(CStringPath, argv);
  13. // You reach this code only if execv returns, which means that something wrong happened.
  14. [targetPath release];
  15. printf("PDFKey Pro is not installed. Please download it from\n");
  16. return 0;
  17. }

Report this snippet  

You need to login to post a comment.