• 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: Download fileSystem data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Download fileSystem data


  • Subject: Re: Download fileSystem data
  • From: Ken Thomases <email@hidden>
  • Date: Sat, 30 Nov 2013 05:43:43 -0600

On Nov 30, 2013, at 4:08 AM, Stephen J. Butler wrote:

> Have you profiled your code to see what calls exactly are taking the most
> time? I have a feeling it's these:
>
>    isFilePackageAtPath
>    kLSItemInfoIsInvisible
>    kFSNodeLockedMask
>    kFSCatInfoCreateDate
>    kFSCatInfoContentMod
>    kFSCatInfoBackupDate
>    kFSCatInfoAccessDate
>
> And parsing "ls" output won't get you these (besides, parsing "ls" is a
> dirty hack anyway). You probably want to try dropping down to
> CFURLEnumerator and asking it to prefetch the desired attributes. Or, if
> you're targeting pre-10.6 then FSGetCatalogInfoBulk().

You don't need to drop down to CFURLEnumerator for that.  You can use -[NSFileManager enumeratorAtURL:includingPropertiesForKeys:options:errorHandler:].  Unsurprisingly, the array of property keys asks it to prefetch the desired properties.  Each object returned by the enumerator is an NSURL and you get its properties using -getResourceValue:forKey:error:.  These are the properties which have been prefetched.

Of course, you then have to switch to using the Cocoa property keys rather than the old-style File Manager properties.

NSFileType -> NSURLFileResourceTypeKey
isFilePackageAtPath -> NSURLIsPackageKey
kLSItemInfoIsInvisible -> NSURLIsHiddenKey
kFSNodeLockedMask -> either NSURLIsUserImmutableKey or NSURLIsSystemImmutableKey is TRUE
kFSCatInfoCreateDate -> NSURLCreationDateKey
kFSCatInfoContentMod -> NSURLContentModificationDateKey
kFSCatInfoBackupDate -> no translation, as far as I know
kFSCatInfoAccessDate -> NSURLContentAccessDateKey

If you absolutely must have the backup date, rather than dropping back to the old File Manager API, I would recommend using the getdirentriesattr() function.  It may support the ATTR_CMN_BKUPTIME attribute if the volume and the file system driver support it:
https://developer.apple.com/library/mac/documentation/darwin/Reference/ManPages/man2/getdirentries.2.html

All of that said, there's no guarantee that remote file system access is ever going to be especially speedy.

Regards,
Ken


_______________________________________________

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


References: 
 >Download fileSystem data (From: Leonardo <email@hidden>)
 >Re: Download fileSystem data (From: "Stephen J. Butler" <email@hidden>)

  • Prev by Date: Re: Fast hash of NSData?
  • Next by Date: NSShadowAttributeName doesn't scale
  • Previous by thread: Re: Download fileSystem data
  • Next by thread: Re: Download fileSystem data
  • Index(es):
    • Date
    • Thread