File-level filesystem change notification in Mac OS X

后端 未结 4 853
难免孤独
难免孤独 2021-02-01 04:08

I want my code to be notified when any file under (either directly or indirectly) a given directory is modified. By \"modified\", I mean I want my code to be notified whenever

4条回答
  •  醉话见心
    2021-02-01 04:33

    I haven't tried this myself, but it seems like FSEvents is able to provide file-level notifications as of 10.7 (Lion). From the description of FSEventStreamCreateFlags:

    kFSEventStreamCreateFlagFileEvents

    Request file-level notifications. Your stream will receive events about individual files in the hierarchy you're watching instead of only receiving directory level notifications. Use this flag with care as it will generate significantly more events than without it.

    Available in OS X v10.7 and later.

提交回复
热议问题