Re: question about last used date
Re: question about last used date
- Subject: Re: question about last used date
- From: Jens Alfke <email@hidden>
- Date: Mon, 14 Mar 2016 08:39:56 -0700
> On Mar 14, 2016, at 2:24 AM, Rick C. <email@hidden> 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 (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