inotify.py 文件源码

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

项目:centos-base-consul 作者: zeroc0d3lab 项目源码 文件源码
def watch(self, path):
        ''' Register a watch for the file/directory named path. Raises an OSError if path
        does not exist. '''
        path = realpath(path)
        with self.lock:
            if path not in self.watches:
                bpath = path if isinstance(path, bytes) else path.encode(self.fenc)
                flags = self.MOVE_SELF | self.DELETE_SELF
                buf = ctypes.c_char_p(bpath)
                # Try watching path as a directory
                wd = self._add_watch(self._inotify_fd, buf, flags | self.ONLYDIR)
                if wd == -1:
                    eno = ctypes.get_errno()
                    if eno != errno.ENOTDIR:
                        self.handle_error()
                    # Try watching path as a file
                    flags |= (self.MODIFY | self.ATTRIB)
                    wd = self._add_watch(self._inotify_fd, buf, flags)
                    if wd == -1:
                        self.handle_error()
                self.watches[path] = wd
                self.modified[path] = False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号