File monitoring using Grand Central Dispatch

后端 未结 2 966
眼角桃花
眼角桃花 2020-12-16 21:36

I\'m using the code example by David Hamrick to monitor a file using GCD.

int fildes = open(\"/path/to/config.plist\", O_RDONLY);

dispatch_queue_t queue = d         


        
2条回答
  •  我在风中等你
    2020-12-16 22:24

    After a little bit a research I found out :

    => I was getting the flag DISPATCH_VNODE_DELETE

    I was monitoring ~/Library/Preferences/com.apple.dock.plist As I found out, changing the dock orientation, deletes the original file and replaces it with a new one.

    Therefore, the monitoring stopped.

    The same author proposes a solution where in case of deletion, the GCD block call itself to continue the monitoring.

提交回复
热议问题