What is the optimal way to monitor changes in a directory with a kqueue()?

做~自己de王妃 提交于 2019-11-28 11:14:36

This is only a partial answer, but might be somewhat useful.

  1. The kqueue mechanism indeed does work as a means to be notified when an app's Documents directory is modified.

  2. The notification comes as soon as the directory is modified and before copying a file is complete. I have observed this in testing.

Unfortunately, there is no form of notification when the copy is done. At least, none that I have found.

What I hope Apple will realize is there needs to be a notification for "iTunes synch" is done, because this seems to be a general problem.

A loop checking if the new file's modification time is not changing might work, but only most of the time. In some extreme circumstances, iOS can pause to do all kinds of time consuming work of its own in the background.

If there is a way to check if a particular file is open by another process, then this would be enough.

Geoff

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!