Thanks for the replies and yeah I get what you're saying.  The only thing with 
the spotlight metadata is it will depend on the spotlight index being enabled 
correct?  And yes it is the opened date I'm looking for. 

One more note, seems in terminal "stat aFile" works so I suppose I could use 
nstask to do this as well?  I was just thinking there was a better way. 

rc

  

On Jul 8, 2011, at 1:04 PM, Joar Wingfors <j...@joar.com> wrote:

> Hello Rick,
> 
> The access date on a file is updated very frequently. I think that stat:ing 
> the file is enough, and that happens all the time.
> 
> If what you're looking for is the last *opened* date of the file, I think 
> that your best bet is the kMDItemLastUsedDate spotlight metadata attribute.
> 
> j o a r
> 
> 
> On 7 jul 2011, at 20:35, Rick C. wrote:
> 
>> Hi again,
>> 
>> I'm using this code to get the last accessed date of a file:
>> 
>> struct stat output;
>> 
>>   int ret = stat([aFile fileSystemRepresentation], &output);
>>   struct timespec accessTime = output.st_atimespec;
>>  NSDate *aDate = [NSDate dateWithTimeIntervalSince1970:accessTime.tv_sec];
>> 
>>   NSLog(@"Access Time %d, %@",ret, aDate);
>> 
>> But it's just giving me today's date.  There must be something obvious I'm 
>> doing wrong but I have not been able to figure it out.  Any pointers?  And I 
>> couldn't use NSURLContentAccessDate because I still need 10.5 support.  
>> Thanks!
>> 
>> rc_______________________________________________
>> 
>> 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:
>> http://lists.apple.com/mailman/options/cocoa-dev/joar%40joar.com
>> 
>> This email sent to j...@joar.com
> 
_______________________________________________

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

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

Reply via email to