• 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: How to determine if any intermediate directory in path is link?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to determine if any intermediate directory in path is link?


  • Subject: Re: How to determine if any intermediate directory in path is link?
  • From: Citizen <email@hidden>
  • Date: Mon, 4 Jun 2007 15:40:18 +0100

Hi Sharad,

On 4 Jun 2007, at 14:36, sharad saxena wrote:

Is there any cocoa API to determine if a path is a *real path* and none of
its *intermediate* directories is link?

You can determine if a particular path points to a Symbolic Link (a Unix style link) using:
[[[NSFileManager defaultManager] fileAttributesAtPath:workingPath traverseLink:NO] fileType] == NSFileTypeSymbolicLink


You can also determine if a particular path points to a Finder Alias using something like this:

// returns YES if aPath is a Finder Alias
- (BOOL) isFinderAliasAtPath:(NSString *)aPath
{
if ([[NSFileManager defaultManager] fileExistsAtPath:aPath]) {
FSRef fileRef;
FSCatalogInfo catalogInfo;
FileInfo * fileInfo;
FSCatalogInfoBitmap catalogInfoBitmap = kFSCatInfoFinderInfo;

if (FSPathMakeRef((const UInt8 *)[aPath fileSystemRepresentation], &fileRef, NULL) == noErr) {
if (FSGetCatalogInfo(&fileRef, catalogInfoBitmap, &catalogInfo, NULL, NULL, NULL) == noErr) {
fileInfo = (FileInfo *) &catalogInfo.finderInfo;
if ((fileInfo->finderFlags & kIsAlias) == kIsAlias) {
return YES;
}
}
}
}
return NO;
}


With either of these you would need to iterate from the beginning of the path to determine if any of the intermediate directories are a link.

Hope that helps,
Dave

------
David Kennedy (http://www.zenopolis.com)



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >How to determine if any intermediate directory in path is link? (From: "sharad saxena" <email@hidden>)

  • Prev by Date: Re: RS: NSString from RTF file
  • Next by Date: Re: RS: NSString from RTF file
  • Previous by thread: How to determine if any intermediate directory in path is link?
  • Next by thread: Core Data NSPersistentDocument and revert
  • Index(es):
    • Date
    • Thread