Where does the finder get the “added date” of an item in the folder?

If the folder is placed in the Dock, you can sort it by the "added date" - usually this is the default value for the "Downloads" folder. (Sometimes Finder does not seem to use the added date, but changed the date, but can find the added date.) Where does Finder understand this? The standard metadata of the file, that is, obtained using stat, getattrlist or FSGetCatInfo) does not contain it. TIA

+3
source share
2 answers

Yes, the added date can be inferred from other structures. In fact, it is in the 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;
}
+9
source

Note: deprecated now that Lions out.

Finder is not, Dock is. . , " " .

+1

All Articles