Ë
    oj²  ã                   ó<  — d Z ddlZddlZddlmZmZ ddlmZ  G d„ de«      Z	de
fd„Zd	e
d
ee   de
de
fd„Zd	e
de
ddfd„Zdej                  ddfd„Zej                   j#                  d«      Zes ed«      ‚ej(                  j+                  e«      Z ee«       y)zŒ
Very low-level ctypes-based interface to Linux inotify(7).

ctypes and a version of libc which supports inotify system calls are
required.
é    N)ÚAnyÚcast)ÚFilePathc                   ó   — e Zd ZdZy)ÚINotifyErrorzR
    Unify all the possible exceptions that can be raised by the INotify API.
    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    ú9/usr/lib/python3/dist-packages/twisted/python/_inotify.pyr   r      s   „ òr   r   Úreturnc                  ój   — t        t        t        j                  «       «      } | dk  rt	        d«      ‚| S )zO
    Create an inotify instance and return the associated file descriptor.
    r   zINotify initialization error.)r   ÚintÚlibcÚinotify_initr   )Úfds    r   Úinitr      s1   € ô 
Œc”4×$Ñ$Ó&Ó	'€BØ	ˆA‚vÜÐ:Ó;Ð;Ø€Ir   r   ÚpathÚmaskc                 ó®   — t        t        t        j                  | |j	                  «       j
                  |«      «      }|dk  rt        d|›d|›d�«      ‚|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}.
    @param path: The path to watch via inotify.
    @param mask: Bitmask specifying the events that inotify should monitor.
    r   zFailed to add watch on 'z' - (ú))r   r   r   Úinotify_add_watchÚasBytesModer   r   )r   r   r   Úwds       r   Úaddr   #   sU   € ô 
Œc”4×)Ñ)¨"¨d×.>Ñ.>Ó.@×.EÑ.EÀtÓLÓ	M€BØ	ˆA‚vÜÐ5°d°X¸UÀ2À&ÈÐJÓKÐKØ€Ir   r   c                 ó0   — t         j                  | |«       y)zM
    Remove the given watch descriptor from the inotify file descriptor.
    N)r   Úinotify_rm_watch)r   r   s     r   Úremover    2   s   € ô0 	×Ñ˜"˜bÕ!r   r   c                 óø  — dD ]  }t        | |d«      �Œt        d«      ‚ g | j                  _        t        j
                  | j                  _        t        j
                  t        j
                  g| j                  _        t        j
                  | j                  _        t        j
                  t        j                  t        j                  g| j                  _        t        j
                  | j                  _        y)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   Nzlibc6 2.4 or higher needed)ÚgetattrÚImportErrorr   ÚargtypesÚctypesÚc_intÚrestyper   Úc_char_pÚc_uint32r   )r   Úfunctions     r   ÚinitializeModuler+   M   s±   € ð Nò <ˆÜ�4˜ 4Ó(Ñ0ÜÐ:Ó;Ð;ð<ð "$€D×ÑÔÜ &§¡€D×ÑÔä&,§l¡l´F·L±LÐ%A€D×ÑÔ"Ü$*§L¡L€D×ÑÔ!ä'-§|¡|´V·_±_ÄfÇoÁoÐ&V€D×ÑÔ#Ü%+§\¡\€D×ÑÕ"r   ÚczCan't find C library.)r   r%   Úctypes.utilÚtypingr   r   Útwisted.python.filepathr   Ú	Exceptionr   r   r   r   r    ÚCDLLr+   ÚutilÚfind_libraryÚnamer#   ÚcdllÚLoadLibraryr   r   r   r   ú<module>r7      sÇ   ðñ
ó Û ß å ,ô�9ô ðˆcó ðˆCð �x ‘}ð ¨Cð °Có ð"ˆsð "˜ð " ó "ð62˜6Ÿ;™;ð 2¨4ó 2ð& ‡{�{×Ñ Ó$€ÙÙ
Ð-Ó
.Ð.Ø‡{�{×Ñ˜tÓ$€Ù �Õ r   