Ë
    #täig  ã                  ó†  — d dl mZ d dlZd dlZd dlmZ d dlmZ d dlm	Z	 d dl
mZ ddlmZ dd	lmZmZ ej"                  d
k(  rpd dlZd dlZd dlmZ dZdZ ej.                  dd¬«      Zej2                  gej4                  _        ej8                  ej4                  _        dd„Z G d„ de«      ZdgZ y G d„ de«      ZdgZ y)é    )ÚannotationsN)Úsuppress)ÚEACCES)ÚPath)Úcasté   )ÚBaseFileLock)Úensure_directory_existsÚraise_on_not_writable_fileÚwin32)Úwintypesi   l   ÿÿ Úkernel32T)Úuse_last_errorc                ó¤   — t         j                  | «      }|t        k(  r!t        j                  «       }|dk(  ry|dk(  ryyt        |t        z  «      S )a  
        Check if a path is a reparse point (symlink, junction, etc.) on Windows.

        :param path: Path to check

        :returns: True if path is a reparse point, False otherwise

        :raises OSError: If GetFileAttributesW fails for reasons other than file-not-found

        é   Fé   )Ú	_kernel32ÚGetFileAttributesWÚINVALID_FILE_ATTRIBUTESÚctypesÚget_last_errorÚboolÚFILE_ATTRIBUTE_REPARSE_POINT)ÚpathÚattrsÚerrs      ú`/Volumes/fast/ai/experiments/MLX_z-image/.venv/lib/python3.12/site-packages/filelock/_windows.pyÚ_is_reparse_pointr      sS   € ô ×,Ñ,¨TÓ2ˆØÔ+Ò+ä×'Ñ'Ó)ˆCØ�aŠxØØ�aŠxØàÜ�EÔ8Ñ8Ó9Ð9ó    c                  ó    — e Zd ZdZdd„Zdd„Zy)ÚWindowsFileLocka~  
        Uses the :func:`msvcrt.locking` function to hard lock the lock file on Windows systems.

        Lock file cleanup: Windows attempts to delete the lock file after release, but deletion is
        not guaranteed in multi-threaded scenarios where another thread holds an open handle. The lock
        file may persist on disk, which does not affect lock correctness.
        c                ó˜  — t        | j                  «       t        | j                  «       t        | j                  «      rd| j                  › �}t	        |«      ‚t
        j                  t
        j                  z  }	 t        j                  | j                  || j                  «       «      }	 t        j                  |t        j                  d«       || j                  _        y # t        $ r3}t        j                  |«       |j                   t"        k7  r‚ Y d }~y d }~ww xY w# t        $ r}|j                   t"        k7  r‚ Y d }~y d }~ww xY w)Nz1Lock file is a reparse point (symlink/junction): r   )r   Ú	lock_filer
   r   ÚOSErrorÚosÚO_RDWRÚO_CREATÚopenÚ
_open_modeÚmsvcrtÚlockingÚLK_NBLCKÚ_contextÚlock_file_fdÚcloseÚerrnor   )ÚselfÚmsgÚflagsÚfdÚ	exceptions        r   Ú_acquirezWindowsFileLock._acquire;   sü   € Ü& t§~¡~Ô6Ü# D§N¡NÔ3ô ! §¡Ô0ØIÈ$Ï.É.ÐIYÐZ�Ü˜c“lÐ"ô —	‘	Ü—*‘*ñð ð4Ü—W‘W˜TŸ^™^¨U°D·O±OÓ4EÓF�ð
4Ü—N‘N 2¤v§¡¸Ô:ð 24�D—M‘MÕ.øô ò Ü—H‘H˜R”LØ —‘¬&Ò0Øô 1ûðûô ò Ø—?‘?¤fÒ,Øô -ûðús0   Á</D" Â,%C# Ã#	DÃ,)DÄDÄ"	E	Ä+EÅE	c                óh  — t        d| j                  j                  «      }d | j                  _        t        j                  |t        j
                  d«       t        j                  |«       t        t        «      5  t        | j                  «      j                  «        d d d «       y # 1 sw Y   y xY w)NÚintr   )r   r-   r.   r*   r+   ÚLK_UNLCKr%   r/   r   r$   r   r#   Úunlink)r1   r4   s     r   Ú_releasezWindowsFileLock._releaseX   sl   € Ü�e˜TŸ]™]×7Ñ7Ó8ˆBØ)-ˆD�M‰MÔ&Ü�N‰N˜2œvŸ™°Ô2Ü�H‰H�RŒLäœ'Õ"Ü�T—^‘^Ó$×+Ñ+Ô-÷ #×"Ñ"ús   Á;$B(Â(B1N©ÚreturnÚNone©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r6   r;   © r   r   r!   r!   2   s   „ ñ	ó	4ô:	.r   r!   c                  ó    — e Zd ZdZdd„Zdd„Zy)r!   zWUses the :func:`msvcrt.locking` function to hard lock the lock file on Windows systems.c                ó   — t         ‚©N©ÚNotImplementedError©r1   s    r   r6   zWindowsFileLock._acquiref   ó   € Ü%Ð%r   c                ó   — t         ‚rG   rH   rJ   s    r   r;   zWindowsFileLock._releasei   rK   r   Nr<   r?   rD   r   r   r!   r!   c   s   „ Ùeó	&ô	&r   )r   Ústrr=   r   )!Ú
__future__r   r%   ÚsysÚ
contextlibr   r0   r   Úpathlibr   Útypingr   Ú_apir	   Ú_utilr
   r   Úplatformr   r*   r   r   r   ÚWinDLLr   ÚLPCWSTRr   ÚargtypesÚDWORDÚrestyper   r!   Ú__all__rD   r   r   Ú<module>r\      s¶   ðÝ "ã 	Û 
Ý Ý Ý Ý å ß Fà‡<�<�7ÒÛÛÝð $.Ð Ø(Ðð �—‘˜j¸Ô>€IØ-5×-=Ñ-=Ð,>€I× Ñ Ô)Ø+3¯>©>€I× Ñ Ô(ó:ô.-.˜,ô -.ðx ð�ô&˜,ô &ð ð�r   