Cocoa, FSEvents, kFSEventStreamCreateFlagFileEvents flag and “renamed” events

前端 未结 3 1397
逝去的感伤
逝去的感伤 2021-02-09 06:11

I\'ve been playing with FSEvents in a little application of mine to synchronize the content of my application with what\'s on the hard drive (basically, it\'s a lit

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-09 06:52

    You need to use the flag kFSEventStreamCreateFlagUseExtendedData (available since OS X 10.13). A stream created with that flag will include the inode of the event file. That way you can detect "rename chains" that happened in a reported event batch.

    P.S. macOS may reuse the inode of a deleted file for a newly created one, although if you process the events right away, the risk is negligible.

提交回复
热议问题