I think the NSURL methods are actually the “preferred” way to do it these days 
on the Mac, since the NSFileManager method takes paths, and URLs are clearly 
the direction that Apple is moving.

In addition to NSURLFileSizeKey and NSURLFileAllocatedSizeKey, which will give 
you the logical and physical sizes of the data fork, NSURL also provides 
NSURLTotalFileSizeKey and NSURLTotalFileAllocatedSizeKey, which will include 
the size of the resource fork and any other extended attributes the file may 
have.

Charles

On Aug 31, 2011, at 3:21 PM, Kyle Sluder wrote:

> On Wed, Aug 31, 2011 at 12:51 PM, Jon Sigman <[email protected]> wrote:
>> How does one determine the size of a file on disk using Cocoa?
>> I've looked at NSFileManager but it doesn't seem to offer any
>> methods for finding file attributes.
> 
> You mean other than -attributesOfItemAtPath:error:?
> 
> http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html
> 
> Or -[NSURL resourceValuesForKeys:error:], which is newer, unsupported
> on iOS, and the existence of which I find mysterious:
> http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html
> 
> --Kyle Sluder
> _______________________________________________
> 
> Cocoa-dev mailing list ([email protected])
> 
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40charlessoft.com
> 
> This email sent to [email protected]

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to