Well, directories -are- a single file so it makes sense that the file size refers to exactly the directory and not its contents. Besides, for the general case of looking at files/folders in a particular directory, you could get all the attributes quickly without paying a time penalty to recursively calculate the total file size until you decide that you actually need that information.

As for choosing to use Carbon, making that decision based on what the Finder is or isn't doing is not very relevant. Not everything has been made "native" Cocoa, or a Carbon solution might be better for a particular task. If you don't want to see procedural calls in your general code, just wrap the Carbon bits in a Cocoa method wrapper and claim blissful ignorance of the implementation. :)


On Apr 7, 2009, at 9:04 PM, Jo Phils wrote:

Thank you I.S. and all who replied! :-)

It's my understanding that [NSFileManager fileAttributesAtPath:traverseLink:] will do fine for a single file but for directories it won't include the sizes of the subdirectories as Finder does. That's what I got in my testing as well but maybe I'm missing something?

As for not using Carbon I suppose there's no reason I can't use it. I was just thinking with Finder going away from Carbon and since I'm just learning Cocoa I was trying to avoid it if I could. But if it's the best way I can use it...

Thank you very much,

Rick

________________________________
From: I. Savant <idiotsavant2...@gmail.com>
To: Jo Phils <jo_p...@yahoo.com>
Cc: cocoa dev <cocoa-dev@lists.apple.com>
Sent: Tuesday, April 7, 2009 11:13:19 PM
Subject: Re: finder file size

On Tue, Apr 7, 2009 at 11:09 AM, Jo Phils <jo_p...@yahoo.com> wrote:

My apologies if this has been answered before but isn't there a simple way to get the file size as it shows under Size in Finder without using Carbon and without enumerating the directory? My understanding is NSFileSize will not do it?

  Have you tried searching the archives? How about Google?

  See -[NSFileManager fileAttributesAtPath:traverseLink:] ... it
includes a fileSize attribute.

--
I.S.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to