• 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: Get size of folder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get size of folder


  • Subject: Re: Get size of folder
  • From: Alastair Houghton <email@hidden>
  • Date: Wed, 19 Aug 2009 10:24:26 +0100

On 19 Aug 2009, at 09:03, Charles Srstka wrote:

On Aug 19, 2009, at 2:59 AM, Jean-Daniel Dupas wrote:

I think you have to add data and resource sizes to match the Finder behavior (which are two distinct field in the catalog info).

Ah, you're right. This probably makes Carbon's file manager the most convenient way to do it (I believe it's also the best performing).

As I think I may have mentioned before, contrary to apparently widespread opinion, Carbon isn't magic. The Carbon file manager APIs are based on BSD APIs, and calling the BSD APIs in question is going to be faster if you really need high performance because they don't have to map things to the Carbon API's data structures and back again.


*However*, Carbon is often a good choice because you don't have to worry about whether the filesystem supports getattrlist(), searchfs(), getdirentriesattr() et al.

In this particular instance though, while the attraction of FSGetCatalogInfoBulk() is obvious, I worry that it'd be easy to mess up when implementing recursive directory traversal. It might be better to use fts() with the FTS_NOSTAT option and then call getattrlist().

However, if you use another method, you can still get the resource fork size by appending /..namedfork/rsrc to the end of the path for each regular file.

Or by using getattrlist() or getdirentriesattr() with ATTR_FILE_DATALENGTH and ATTR_FILE_RSRCLENGTH (or ATTR_FILE_DATAALLOCSIZE and ATTR_FILE_RSRCALLOCSIZE if that's what you want), remembering of course that not all filesystems necessarily support those APIs. If a volume doesn't support getattrlist(), it's very unlikely to have any kind of resource for support.


Kind regards,

Alastair.

--
http://alastairs-place.net



_______________________________________________

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


  • Follow-Ups:
    • Re: Get size of folder
      • From: Charles Srstka <email@hidden>
References: 
 >Get size of folder (From: PCWiz <email@hidden>)
 >Re: Get size of folder (From: Charles Srstka <email@hidden>)
 >Re: Get size of folder (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Get size of folder (From: Charles Srstka <email@hidden>)

  • Prev by Date: Re: int to bytes(value in NSString)
  • Next by Date: Re: Get size of folder
  • Previous by thread: Re: Get size of folder
  • Next by thread: Re: Get size of folder
  • Index(es):
    • Date
    • Thread