emcrisostomo / fswatch

A cross-platform file change monitor with multiple backends: Apple OS X File System Events, *BSD kqueue, Solaris/Illumos File Events Notification, Linux inotify, Microsoft Windows and a stat()-based backend.
https://emcrisostomo.github.io/fswatch/
GNU General Public License v3.0
5.06k stars 330 forks source link

how to notify when file is created under the directory which is being watching, by using kqueue? #205

Closed seekforwings closed 6 years ago

seekforwings commented 6 years ago

https://github.com/emcrisostomo/fswatch/blob/ce91bbe6df926c59566c6522cba8cfe21c6409cd/libfswatch/src/libfswatch/c%2B%2B/kqueue_monitor.cpp#L84

seekforwings commented 6 years ago

@emcrisostomo well, could you please tell me whether there is anyway to notify the creation of a file with kqueue?

emcrisostomo commented 6 years ago

@seekforwings, well, that's a general question about kqueue and not a fswatch issue. Unless you've got one, please direct your general question elsewhere if you expect them to be promptly answered.

I suggest you consult the kqueue man page where you'll find the answer.

seekforwings commented 6 years ago

@emcrisostomo , is it better to use fsevent rather than kqueue on osx system? On some BSD system, kqueue can be used. However, I'd read the code but I couldn't find out any way to notify when a file is created. And the man page seems to be not talking about this kind of event. So, this is why I wanted to ask and I did ask here.

seekforwings commented 6 years ago

The code I read is here: fswatch/libfswatch/src/libfswatch/c++/kqueue_monitor.cpp

seekforwings commented 6 years ago

You can see that there is no flag like file creation:

qq 20180508110739

seekforwings commented 6 years ago

Comparing with FSEvent in fswatch/libfswatch/src/libfswatch/c++/fsevents_monitor.cpp qq 20180508111004