Ë
    ¹ûàg  ã                   ó:  — d Z ddlZdZd„ Zej                  dk(  r¹ddlZddlmZmZm	Z	m
Z
mZmZmZmZmZ ddlmZmZmZ dZdZd	Z ee«       ee«      k7  reZneZeZ G d
„ de«      Z G d„ de	«      Z G d„ de«      Z ee«      Z e
d«      Zej<                  Zee_        eeeeeege_         ejB                  Z!ee!_        eeeeege!_         d„ Z"d„ Z#y	 ddl$Z$e$j(                  Ze$j*                  Ze$j,                  Zd„ Z"d„ Z#y# e%e&f$ r dxZxZZd„ Z"d„ Z#Y yw xY w)am  
Portable file locking utilities.

Based partially on an example by Jonathan Feignberg in the Python
Cookbook [1] (licensed under the Python Software License) and a ctypes port by
Anatoly Techtonik for Roundup [2] (license [3]).

[1] https://code.activestate.com/recipes/65203/
[2] https://sourceforge.net/p/roundup/code/ci/default/tree/roundup/backends/portalocker.py  # NOQA
[3] https://sourceforge.net/p/roundup/code/ci/default/tree/COPYING.txt

Example Usage::

    >>> from django.core.files import locks
    >>> with open('./file', 'wb') as f:
    ...     locks.lock(f, locks.LOCK_EX)
    ...     f.write('Django')
é    N)ÚLOCK_EXÚLOCK_SHÚLOCK_NBÚlockÚunlockc                 ó>   — t        | d«      r| j                  «       S | S )zCGet a filedescriptor from something which could be a file or an fd.Úfileno)Úhasattrr	   ©Úfs    úU/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/django/core/files/locks.pyÚ_fdr      s   € ä   HÔ-ˆ1�8‰8‹:Ð4°1Ð4ó    Únt)	ÚPOINTERÚ	StructureÚUnionÚWinDLLÚbyrefÚc_int64Úc_ulongÚc_void_pÚsizeof)ÚBOOLÚDWORDÚHANDLEé   é   c                   ó   — e Zd ZdefdefgZy)Ú_OFFSETÚOffsetÚ
OffsetHighN)Ú__name__Ú
__module__Ú__qualname__r   Ú_fields_© r   r   r    r    :   s   „ Ø˜uÐ%¨°eÐ'<Ð=‰r   r    c                   ó"   — e Zd ZdgZdefdefgZy)Ú_OFFSET_UNIONÚ_offsetÚPointerN)r#   r$   r%   Ú_anonymous_r    ÚPVOIDr&   r'   r   r   r)   r)   =   s   „ Ø �kˆØ Ð(¨9°eÐ*<Ð=‰r   r)   c                   ó.   — e Zd ZdgZdefdefdefdefgZy)Ú
OVERLAPPEDÚ_offset_unionÚInternalÚInternalHighÚhEventN)r#   r$   r%   r,   Ú	ULONG_PTRr)   r   r&   r'   r   r   r/   r/   A   s1   „ Ø&Ð'ˆà˜Ð#Ø˜YÐ'Ø˜mÐ,Ø�vÐð	
‰r   r/   Úkernel32c           
      óš   — t        j                  t        | «      «      }t        «       }t	        ||dddt        |«      «      }t        |«      S ©Nr   l     þ )ÚmsvcrtÚget_osfhandler   r/   Ú
LockFileExr   Úbool)r   ÚflagsÚhfileÚ
overlappedÚrets        r   r   r   U   s@   € Ü×$Ñ$¤S¨£VÓ,ˆÜ“\ˆ
Ü˜  q¨!¨Z¼¸zÓ9JÓKˆÜ�C‹yÐr   c           	      ó˜   — t        j                  t        | «      «      }t        «       }t	        |dddt        |«      «      }t        |«      S r7   )r8   r9   r   r/   ÚUnlockFileExr   r;   )r   r=   r>   r?   s       r   r   r   [   s>   € Ü×$Ñ$¤S¨£VÓ,ˆÜ“\ˆ
Ü˜5 ! Q¨
´E¸*Ó4EÓFˆÜ�C‹yÐr   c                 ób   — 	 t        j                  t        | «      |«       y# t        $ r Y yw xY w)NTF)ÚfcntlÚflockr   ÚBlockingIOError©r   r<   s     r   r   r   w   s.   € ðÜ—‘œC ›F EÔ*ØøÜ"ò Ùðús   ‚" ¢	.­.c                 ó^   — t        j                  t        | «      t         j                  «       y©NT)rC   rD   r   ÚLOCK_UNr   s    r   r   r   ~   s   € Ü�K‰Kœ˜A›¤§¡Ô.Ør   c                  ó   — y)NFr'   rF   s     r   r   r   m   s   € àr   c                  ó   — yrH   r'   r   s    r   r   r   q   s   € àr   )'Ú__doc__ÚosÚ__all__r   Únamer8   Úctypesr   r   r   r   r   r   r   r   r   Úctypes.wintypesr   r   r   r   r   r   r4   r-   r    r)   r/   ÚLPOVERLAPPEDr5   r:   ÚrestypeÚargtypesrA   r   r   rC   ÚImportErrorÚAttributeErrorr'   r   r   ú<module>rW      sa  ðñó& 
à
=€ò5ð
 ‡7�7ˆd‚?Û÷
÷ 
õ 
÷ 4Ñ3à€GØ€GØ€Gñ ˆgƒ™& Ó*Ò*Ø‰	àˆ	Ø€Eô>�)ô >ô>˜ô >ô
�Yô 
ñ ˜:Ó&€Lñ �jÓ!€HØ×$Ñ$€JØ€JÔØ! 5¨%°¸¸|ÐL€JÔØ×(Ñ(€LØ€LÔØ# U¨E°5¸,ÐG€LÔòóðÛà—-‘-ˆØ—-‘-ˆØ—-‘-ˆò 	ó	øð- ˜Ð(ò à&'Ð'ˆÐ'�'˜Gò	ô	ðús   Ã(D ÄDÄD