inotify.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:dotfiles 作者: gbraad 项目源码 文件源码
def add_watch(self, path):
        bpath = path if isinstance(path, bytes) else path.encode(self.fenc)
        wd = self._add_watch(
            self._inotify_fd,
            ctypes.c_char_p(bpath),

            # Ignore symlinks and watch only directories
            self.DONT_FOLLOW | self.ONLYDIR |

            self.MODIFY | self.CREATE | self.DELETE |
            self.MOVE_SELF | self.MOVED_FROM | self.MOVED_TO |
            self.ATTRIB | self.DELETE_SELF
        )
        if wd == -1:
            eno = ctypes.get_errno()
            if eno == errno.ENOTDIR:
                return False
            raise OSError(eno, 'Failed to add watch for: {0}: {1}'.format(path, self.os.strerror(eno)))
        self.watched_dirs[path] = wd
        self.watched_rmap[wd] = path
        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号