• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Creating alias to app for PDFService
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating alias to app for PDFService


  • Subject: Re: Creating alias to app for PDFService
  • From: Antonio Nunes <email@hidden>
  • Date: Sun, 30 Apr 2006 16:38:06 +0100

Thanks James. With your help a bit more tinkering enabled me to find the solution. I shouldn't be calling linkPath:toPath:, but createSymbolicLinkAtPath:pathContent: instead to create aliases. With that call, creating the alias is easy peasy. I list the corrected and expanded complete method here in case it's of any use to anybody. Note that this code only looks in the user's library folder, it ignores the option of installing the service for all users.

-António

- (IBAction)installAsPDFService:(id)sender
{
NSArray *paths;
BOOL isDir = NO, exists = NO, success = NO;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *pdfServiceDirectoryPath, *myAppAliasPath, *myAppPath;

paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
if ([paths count] > 0) { // only looking for one file/directory
pdfServiceDirectoryPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"PDF Services"];
exists = [fileManager fileExistsAtPath:pdfServiceDirectoryPath isDirectory:&isDir];
if (!isDir) {
// There is no PDF Services directory so create it
success = [fileManager createDirectoryAtPath:pdfServiceDirectoryPath attributes:nil];
if (!success) {
NSRunAlertPanel(@"myApp", @"Could not create the \"PDF Services\" directory", @"OK", NULL, NULL);
return;
}
}

myAppAliasPath = [pdfServiceDirectoryPath stringByAppendingPathComponent:@"myApp"];
exists = [fileManager fileExistsAtPath:myAppAliasPath];
if (!exists) {
// There is no alias to myApp so create it
myAppPath = [[NSBundle mainBundle] bundlePath];
success = [fileManager createSymbolicLinkAtPath:myAppAliasPath pathContent:myAppPath];
if (success) {
NSRunAlertPanel(@"myApp", @"Successfully installed myApp as a PDF service", @"OK", NULL, NULL);
} else {
NSRunAlertPanel(@"myApp", @"Could not install myApp as a PDF service", @"OK", NULL, NULL);
}


} else {
NSRunAlertPanel(@"myApp", @"myApp is already installed as a PDF service", @"OK", NULL, NULL);
}
}
}



_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re: Creating alias to app for PDFService (From: James Bucanek <email@hidden>)

  • Prev by Date: Re: crash on window closing
  • Next by Date: Re: Saving an NSView to a file as an image.
  • Previous by thread: Re: Creating alias to app for PDFService
  • Next by thread: Re: Creating alias to app for PDFService
  • Index(es):
    • Date
    • Thread