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

libfswatch: calling fsw_add_path() after fsw_start_monitor() #179

Closed wolfchimneyrock closed 6 years ago

wolfchimneyrock commented 7 years ago

Hi, I am using libfswatch in a project on linux. Is there a way to dynamically add new paths to the monitor after it has been started?
Right now I it does not have the desired effect, i.e. running fsw_add_path() after fsw_start_monitor() does not start monitoring changes on that new path.

Do I need to re-run fsw_start_monitor() after adding new paths? I am concerned about a big potential performance hit as it is possible there could be a lot of directories changed as the program is running, and I'm not sure how much work fsw_start_monitor() is doing.

t3hk0d3 commented 6 years ago

@wolfchimneyrock You have to just stop monitor (fsw_stop_monitor()), and start it again (fsw_start_monitor()).

emcrisostomo commented 6 years ago

Thanks @t3hk0d3

wangchuanfang commented 6 years ago

I use fswatch_test demo . but, " if (FSW_OK != fsw_start_monitor(*handle)) { fprintf(stderr, " Error creating thread\n"); } " The fsw_start_monitor always reutrun failed. This is why??