Posted By

sudarkoff on 01/19/08


Tagged

trampoline


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

tcol


Installing things to /usr/bin - Trampolines


 / Published in: Objective C
 

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

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];
  7.  
  8. const char *CStringPath = [targetPath UTF8String];
  9. [pool release];
  10.  
  11. execv(CStringPath, argv);
  12.  
  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 http://pdfkey.com\n");
  16. return 0;
  17. }

Report this snippet  

You need to login to post a comment.