Finder在哪里获得“添加的日期”的文件夹中的项目? [英] Where does the Finder obtain the "date added" of an item in a folder?

查看:221
本文介绍了Finder在哪里获得“添加的日期”的文件夹中的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果文件夹放在Dock中,您可以通过添加日期进行排序 - 这通常是下载文件夹的默认值。 (有时Finder似乎没有使用添加的日期,但日期修改,但它可以找到添加的日期。)Finder在哪里找出这个?标准文件元数据,即通过stat,getattrlist或FSGetCatInfo获得的元数据不包含它。 TIA

If a folder is placed in the Dock you can sort it by "date added" - this is usually the default for the Downloads folder. (Sometimes the Finder does not appear to be using the date added but the date modified, but it can find the date added.) Where is the Finder figuring this out from? The standard file metadata, i.e. as obtained by stat, getattrlist or FSGetCatInfo) does not contain it. TIA

推荐答案

是的,添加的日期可以从其他结构推断。实际上,它位于Spotlight元数据中。

Yep, the date added could be inferred from other structures. In fact, it resides in Spotlight metadata.

NSDate *dateAdded(NSURL *url)
{
    NSDate *rslt = nil;
    MDItemRef inspectedRef = nil;

    inspectedRef = MDItemCreateWithURL(kCFAllocatorDefault, (CFURLRef)url);
    if (inspectedRef){
        CFTypeRef cfRslt = MDItemCopyAttribute(inspectedRef, (CFStringRef)@"kMDItemDateAdded");
        if (cfRslt) {
            rslt = (NSDate *)cfRslt;
        }
    }
    return rslt;
}

这篇关于Finder在哪里获得“添加的日期”的文件夹中的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆