> On Mar 14, 2016, at 2:24 AM, Rick C. <rickcort...@gmail.com> wrote:
> 
> My problem is I’m only getting a kMDItemLastUsedDate on about 10% of files I 
> check,

I don’t know whether that attribute is wired up to the filesystem, or whether 
it’s just something that has to be manually updated by app/framework code. From 
what you’re saying, it sounds like the latter; it may be that it has to be 
bumped by e.g. NSDocument when it opens a document.

> even though I always get a value for NSFileModificationDate it still doesn’t 
> seem to always be the true last used date.  

That’s the time the file was last _modified_, not the last time it was _read_.

> For example looking at how Path Finder does it they have an Attribute tag 
> that seems to more correctly give the last date file was used.  Any input 
> here would be appreciated thanks in advance…

Unix filesystems do keep a last-accessed date for files, but it looks like 
NSFileManager doesn’t expose an attribute for it. You can call stat() and get 
the st_atimespec field of the result.

This value may not be as useful as you like, however, because it gets bumped 
any time the file is opened or read from. So I would imagine that background 
processes like Spotlight indexers and Time Machine will touch it, as well as 
Quick Look thumbnail generators.

—Jens


_______________________________________________

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