Re: How to determine if any intermediate directory in path is link?
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