PyGTK/GIO: monitor directory for changes recursively

前端 未结 2 1248
清歌不尽
清歌不尽 2021-02-04 21:17

Take the following demo code (from the GIO answer to this question), which uses a GIO FileMonitor to monitor a directory for changes:

import gio

def directory_c         


        
2条回答
  •  春和景丽
    2021-02-04 22:03

    "Is there an easy way to make it recursive?"

    I'm not aware of any "easy way" to achieve this. The underlying systems, such as inotify on Linux or kqueue on BSDs don't provide facilities to automatically add recursive watches. I'm also not aware of any library layering what you want atop GIO.

    So you'll most likely have to build this yourself. As this can be a bit trick in some corner cases (e.g. mkdir -p foo/bar/baz) I would suggest looking at how pynotify implements its auto_add functionality (grep through the pynotify source) and porting that over to GIO.

提交回复
热议问题