How to read file comment field

后端 未结 2 973
终归单人心
终归单人心 2021-01-13 14:18

In OS X Finder there is \'Comment\' file property. It can be checked in finder by adding \'Comment\' column or edited/checked after right clicking on file or folder and sele

2条回答
  •  忘掉有多难
    2021-01-13 14:56

    Do not use the low-level extended attributes API to read Spotlight metadata. There's a proper Spotlight API for that. (It's called the File Metadata API.) Not only is it a pain in the neck, there's no guarantee that Apple will keep using the same extended attribute to store this information.

    Use MDItemCreateWithURL() to create an MDItem for the file. Use MDItemCopyAttribute() with kMDItemFinderComment to obtain the Finder comment for the item.

提交回复
热议问题