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

This email sent to arch...@mail-archive.com

Reply via email to