← Back
Editing: _inotify.cpython-38.pyc
U W[ � @ st d Z ddlZddlZG dd� de�Zdd� Zdd� Zd d � Zdd� Zej � d �Zes\ed��ej �e�Zee� dS )z� Very low-level ctypes-based interface to Linux inotify(7). ctypes and a version of libc which supports inotify system calls are required. � Nc @ s e Zd ZdZdS )�INotifyErrorzR Unify all the possible exceptions that can be raised by the INotify API. N)�__name__� __module__�__qualname__�__doc__� r r �9/usr/lib/python3/dist-packages/twisted/python/_inotify.pyr s r c C s t �� } | dk rtd��| S )zO Create an inotify instance and return the associated file descriptor. r zINotify initialization error.)�libc�inotify_initr )�fdr r r �init s r c C s0 t �| |�� j|�}|dk r,td||f ��|S )a� Add a watch for the given path to the inotify file descriptor, and return the watch descriptor. @param fd: The file descriptor returned by C{libc.inotify_init}. @type fd: L{int} @param path: The path to watch via inotify. @type path: L{twisted.python.filepath.FilePath} @param mask: Bitmask specifying the events that inotify should monitor. @type mask: L{int} r z"Failed to add watch on '%r' - (%r))r �inotify_add_watchZasBytesMode�pathr )r r �mask�wdr r r �add# s r c C s t �| |� dS )zM Remove the given watch descriptor from the inotify file descriptor. N)r �inotify_rm_watch)r r r r r �remove8 s r c C sp dD ]}t | |d�dkrtd��qg | j_tj| j_tjtjg| j_tj| j_tjtjtj g| j _tj| j _dS )z� Initialize the module, checking if the expected APIs exist and setting the argtypes and restype for C{inotify_init}, C{inotify_add_watch}, and C{inotify_rm_watch}. )r r r Nzlibc6 2.4 or higher needed)�getattr�ImportErrorr Zargtypes�ctypesZc_intZrestyper Zc_char_pZc_uint32r )r Zfunctionr r r �initializeModuleT s � �r �czCan't find C library.)r r Zctypes.util� Exceptionr r r r r �utilZfind_library�namer ZcdllZLoadLibraryr r r r r �<module> s
Save File
Cancel