Installing things to /usr/bin - Trampolines


/ Published in: Objective C
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.