Re: NSFileManager 'attributesOfItemAtPath:error:' does not traverse a link?
Re: NSFileManager 'attributesOfItemAtPath:error:' does not traverse a link?
- Subject: Re: NSFileManager 'attributesOfItemAtPath:error:' does not traverse a link?
- From: Kevin Perry <email@hidden>
- Date: Fri, 28 May 2010 08:33:17 -0700
That documentation is incorrect and is scheduled to be corrected. -attribtuesOfItemAtPath:error: will never automatically resolve symlinks, and that will never change.
-Kevin Perry
On May 28, 2010, at 8:17 AM, Charles Srstka wrote:
> On May 28, 2010, at 10:01 AM, Tito Ciuro wrote:
>
>> The old statement traverses the link:
>>
>> NSDictionary* attr = [[NSFileManager defaultManager] fileAttributesAtPath:file traverseLink:YES];
>>
>> The problem is that the header states that 'attributesOfItemAtPath:error:' that it's a replacement for 'fileAttributesAtPath:traverseLink:', but provides no provision for traversing the link.
>>
>> How would I obtain the attributes of an item that needs to be traversed first?
>
> You can easily traverse a link just by using [file stringByResolvingSymlinksInPath] or [file stringByStandardizingPath] instead of file. Where this gets tricky is if you *don’t* want to resolve the symlink. Currently, the method doesn’t traverse symbolic links, but the documentation claims that this behavior could change in a future version of OS X, so if you need to guarantee that it won’t resolve, the only options are either to use deprecated methods, or to use Carbon or BSD APIs.
>
> Charles_______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please 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
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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