§
    ¿"½jÑA  ã                  ór  — U d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ d dl	m
Z
mZ ddlmZ ddlmZmZ ej        d	k    �rdd dlZd dlZd d
lmZ dZded<   dZded<   dZded<   eez  ez  Zded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZ ded<   dZ!ded <   ee z  e!z  Z"ded!<   dZ#ded"<   dZ$ded#<   dZ%ded$<   d%Z&ded&<   d'Z'ded(<   d Z(ded)<   d*Z)ded+<   d,Z*ded-<   d.Z+ded/<   d0Z,d1ed2<   d3Z-d1ed4<    ej.        d5¦  «        Z/d6ed7<    ej.        d8d9¬:¦  «        Z0d6ed;<    G d<„ d=ej1        ¦  «        Z2 G d>„ d?ej1        ¦  «        Z3 G d@„ dAej1        ¦  «        Z4 G dB„ dCej1        ¦  «        Z5 G dD„ dEej1        ¦  «        Z6ej7        e/j8        _9         ej:        ej;        ¦  «        ej<         ej:        e3¦  «         ej:        e4¦  «         ej:        ej=        ¦  «        ej>        ej>        ej>        ej>        ej?        ej>        ge/j8        _@        ej7        e/jA        _9        ejB         ej:        e2¦  «        ej?        ej?        ge/jA        _@        de/jC        _9         ej:        e2¦  «        ge/jC        _@        ej>        e/jD        _9        ej7        ge/jD        _@        ej;        ge0jE        _@        ejF        e0jE        _9        ej;         ej:        e6¦  «        ge0jG        _@        ejF        e0jG        _9        ej;        ej<        ej<        ej<        ej<         ej:        e5¦  «        ge0jH        _@        ejF        e0jH        _9        ej;        ej<        ej<        ej<         ej:        e5¦  «        ge0jI        _@        ejF        e0jI        _9        dXdJ„ZJdYdL„ZK G dM„ dNe¦  «        ZLdZdS„ZMd[dV„ZNn G dW„ dNe¦  «        ZLdNgZOdS )\é    )ÚannotationsN)Úsuppress)ÚPath)ÚFinalÚcasté   )ÚBaseFileLock)Úensure_directory_existsÚraise_on_not_writable_fileÚwin32)Úwintypesl        z
Final[int]Ú_GENERIC_READi   @Ú_GENERIC_WRITEi   Ú_SYNCHRONIZEÚ_DESIRED_ACCESSé   Ú_FILE_SHARE_READ_WRITEÚ_FILE_OPEN_IFÚ_FILE_ATTRIBUTE_READONLYé€   Ú_FILE_ATTRIBUTE_NORMALi   Ú_FILE_ATTRIBUTE_REPARSE_POINTé    Ú_FILE_SYNCHRONOUS_IO_NONALERTé@   Ú_FILE_NON_DIRECTORY_FILEi    Ú_FILE_OPEN_REPARSE_POINTÚ_CREATE_OPTIONSÚ_OBJ_CASE_INSENSITIVEÚ_OWNER_WRITEÚ_LOCKFILE_FAIL_IMMEDIATELYé   Ú_LOCKFILE_EXCLUSIVE_LOCKé!   Ú_ERROR_LOCK_VIOLATIONÚ_STATUS_SUCCESSl   "    Ú_STATUS_ACCESS_DENIEDl   C    Ú_STATUS_SHARING_VIOLATIONl   V    Ú_STATUS_DELETE_PENDINGg      à?zFinal[float]Ú_ACCESS_DENIED_GRACEgü©ñÒMb`?Ú_ACCESS_DENIED_RETRYÚntdllzFinal[ctypes.WinDLL]Ú_ntdllÚkernel32T)Úuse_last_errorÚ	_kernel32c                  óB   — e Zd Zdej        fdej        fdej        ffZdS )Ú_UNICODE_STRINGÚLengthÚMaximumLengthÚBufferN)Ú__name__Ú
__module__Ú__qualname__r   ÚUSHORTÚLPWSTRÚ_fields_© ó    úQ/home/spazio/kingdom_calls/venv/lib/python3.11/site-packages/filelock/_windows.pyr2   r2   =   s3   € € € € € à�x”Ð'Ø˜hœoÐ.Ø�x”Ð'ð
ˆˆˆr=   r2   c                  ó„   — e Zd Zdej        fdej        fd ej        e¦  «        fdej        fdej	        fdej	        ffZ
dS )Ú_OBJECT_ATTRIBUTESr3   ÚRootDirectoryÚ
ObjectNameÚ
AttributesÚSecurityDescriptorÚSecurityQualityOfServiceN)r6   r7   r8   r   ÚULONGÚHANDLEÚctypesÚPOINTERr2   Úc_void_pr;   r<   r=   r>   r@   r@   D   s[   € € € € € à�x”~Ð&Ø˜hœoÐ.Ø˜>˜6œ>¨/Ñ:Ô:Ð;Ø˜8œ>Ð*Ø! 6¤?Ð3Ø'¨¬Ð9ð
ˆˆˆr=   r@   c                  ó2   — e Zd Zdej        fdej        ffZdS )Ú_IO_STATUS_BLOCKÚStatusÚInformationN)r6   r7   r8   rH   rJ   r;   r<   r=   r>   rL   rL   N   s)   € € € € € à�v”Ð'Ø˜FœOÐ,ð
ˆˆˆr=   rL   c                  ób   — e Zd Zdej        fdej        fdej        fdej        fdej        ffZdS )Ú_OVERLAPPEDÚInternalÚInternalHighÚOffsetÚ
OffsetHighÚhEventN)	r6   r7   r8   rH   rJ   r   ÚDWORDrG   r;   r<   r=   r>   rP   rP   T   sG   € € € € € à˜œÐ)Ø˜Vœ_Ð-Ø�x”~Ð&Ø˜8œ>Ð*Ø�x”Ð'ð
ˆˆˆr=   rP   c                  ó²   — e Zd Zdej        fdej        fdej        fdej        fdej        fdej        fdej        fdej        fd	ej        fd
ej        ff
ZdS )Ú_BY_HANDLE_FILE_INFORMATIONÚdwFileAttributesÚftCreationTimeÚftLastAccessTimeÚftLastWriteTimeÚdwVolumeSerialNumberÚnFileSizeHighÚnFileSizeLowÚnNumberOfLinksÚnFileIndexHighÚnFileIndexLowN)r6   r7   r8   r   rV   ÚFILETIMEr;   r<   r=   r>   rX   rX   ]   s|   € € € € € à ¤Ð0Ø˜xÔ0Ð1Ø Ô!2Ð3Ø Ô 1Ð2Ø# X¤^Ð4Ø˜hœnÐ-Ø˜Xœ^Ð,Ø˜xœ~Ð.Ø˜xœ~Ð.Ø˜hœnÐ-ð
ˆˆˆr=   rX   ÚfdÚintÚreturnÚboolc           
     ó.  — t          ¦   «         }t          t          z  }t                               t          j        | ¦  «        |dddt          j        |¦  «        ¦  «        rdS t          j	        ¦   «         }|t          k    rdS t          j        |¦  «        ‚)Nr   r   TF)rP   r#   r!   r0   Ú
LockFileExÚmsvcrtÚget_osfhandlerH   ÚbyrefÚget_last_errorr%   ÚWinError)rd   Ú
overlappedÚflagsÚerrs       r>   Ú_lock_fd_nonblockingrr   ›   s‚   € õ !‘]”]ˆ
Ý(Õ+EÑEˆÝ×Ò¥Ô 4°RÑ 8Ô 8¸%ÀÀAÀqÍ&Ì,ÐWaÑJbÔJbÑcÔcð 	Ø�4ÝÔ#Ñ%Ô%ˆØÕ'Ò'Ð'Ø�5åŒo˜cÑ"Ô"Ð"r=   ÚNonec           	     óð   — t          ¦   «         }t                               t          j        | ¦  «        dddt          j        |¦  «        ¦  «        s%t          j        t          j        ¦   «         ¦  «        ‚d S )Nr   r   )	rP   r0   ÚUnlockFileExrj   rk   rH   rl   rn   rm   )rd   ro   s     r>   Ú
_unlock_fdrv   ©   sb   € Ý ‘]”]ˆ
å×%Ò%¥fÔ&:¸2Ñ&>Ô&>ÀÀ1ÀaÍÌÐV`ÑIaÔIaÑbÔbð 	;Ý”/¥&Ô"7Ñ"9Ô"9Ñ:Ô:Ð:ð	;ð 	;r=   c                  ó"   — e Zd ZdZdd„Zdd„ZdS )ÚWindowsFileLockay  
        Uses ``LockFileEx`` to hard lock a byte range of 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.
        rf   rs   c                ór  — t          | j        ¦  «         t          | j        ¦  «         t          | j        |                      ¦   «         ¦  «        }|€d S 	 t          |¦  «        }|r|                      |¦  «         n## t          $ r t          j	        |¦  «         ‚ w xY w|st          j	        |¦  «         d S d S ©N)
r   Ú	lock_filer
   Ú_open_non_reparse_fdÚ
_open_moderr   Ú_mark_descriptor_ownedÚBaseExceptionÚosÚclose)Úselfrd   Úlockeds      r>   Ú_acquirezWindowsFileLock._acquire¸   sÈ   € Ý& t¤~Ñ6Ô6Ð6Ý# D¤NÑ3Ô3Ð3õ & d¤n°d·o²oÑ6GÔ6GÑHÔHˆBØˆzØ�ðÝ-¨bÑ1Ô1�Øð 4Ø×/Ò/°Ñ3Ô3Ð3øøÝ ð ð ð Ý”˜‘”�Øðøøøð ð Ý”˜‘”���ðð s   Á&A< Á< Bc                óf  — t          d| j        j        ¦  «        }t          |¦  «         |                      ¦   «          |                      |d¬¦  «         | j        sUt          t          ¦  «        5  t          | j
        ¦  «                             ¦   «          d d d ¦  «         d S # 1 swxY w Y   d S d S )Nre   F)Údefault_suppresses)r   Ú_contextÚlock_file_fdrv   Ú_mark_descriptor_releasedÚ_close_released_fdÚ_preserve_lock_filer   ÚOSErrorr   r{   Úunlink)r‚   rd   s     r>   Ú_releasezWindowsFileLock._releaseË   sñ   € Ý�e˜Tœ]Ô7Ñ8Ô8ˆBõ �r‰NŒNˆNØ×*Ò*Ñ,Ô,Ð,Ø×#Ò# B¸5Ð#ÑAÔAÐAØÔ+ð 2Ý�gÑ&Ô&ð 2ð 2Ý˜œÑ(Ô(×/Ò/Ñ1Ô1Ð1ð2ð 2ð 2ñ 2ô 2ð 2ð 2ð 2ð 2ð 2ð 2ð 2øøøð 2ð 2ð 2ð 2ð 2ð 2ð2ð 2s   Á0'B$Â$B(Â+B(N©rf   rs   ©r6   r7   r8   Ú__doc__r„   rŽ   r<   r=   r>   rx   rx   ¯   sF   € € € € € ð	ð 	ð	ð 	ð 	ð 	ð&
	2ð 
	2ð 
	2ð 
	2ð 
	2ð 
	2r=   rx   ÚpathÚstrÚmodeú
int | Nonec                óÂ  — t          j        d| dt          j        t          j        z  ¦  «         |t
          z   }t          | |¬¦  «        \  }}|t          k    rŒt          j	        ¦   «         t          z   }|t          k    rft          j	        ¦   «         |k     rOt          j        t          ¦  «         t          | |¬¦  «        \  }}|t          k    rt          j	        ¦   «         |k     °O|t          k    rb|t          t          hv rdS t                                |¦  «        }t%          dt'          j        |¦  «                             ¦   «         | |¦  «        ‚t-          ¦   «         }t.                               |t'          j        |¦  «        ¦  «        sAt'          j        ¦   «         }t.                               |¦  «         t'          j        |¦  «        ‚|j        t<          z  r.t.                               |¦  «         d| › �}	t%          |	¦  «        ‚	 t?          j         |t          j        t          j!        z  ¦  «        S # tD          $ r t.                               |¦  «         ‚ w xY w)aÂ  
        Open *path* for locking while refusing reparse points, bound to the handle actually locked.

        The file is opened through ``NtCreateFile`` with ``FILE_OPEN_REPARSE_POINT`` so a symlink or junction planted
        at the path is not followed, and the reparse decision is read from *that* handle via
        ``GetFileInformationByHandle`` rather than from a prior pathname query. Reading the held handle closes the
        check-then-open race: an attacker cannot swap the path between validation and use because both act on the same
        handle. Share mode omits delete so a peer cannot unlink or rename the file out from under a live holder,
        matching ``os.open``'s ``_SH_DENYNO``.

        ``NtCreateFile`` is used instead of ``CreateFileW`` because its return value carries the raw ``NTSTATUS``.
        Windows collapses a transient delete-pending name and a permanent access denial into the same Win32
        ``ERROR_ACCESS_DENIED``; the status keeps them apart, so a real denial fails fast instead of spinning until the
        caller's timeout (#604).

        The reparse option only guards the final path component; Windows still follows reparse points in intermediate
        directories. This assumes the lock file sits in a lock directory untrusted users cannot modify. A path with
        attacker-controlled parent directories would need component-by-component handle validation.

        :param path: the lock file path.
        :param mode: the permission mode; as ``os.open`` does on Windows, a cleared owner-write bit creates the file
            read-only. The attribute only takes effect when the file is created, not when an existing one is opened.

        :returns: a file descriptor owning the opened handle, or ``None`` on a sharing violation or a delete-pending
            name the caller should treat as contention and retry.

        :raises OSError: if the path resolves to a reparse point, or the open fails for any other reason, raised with
            the Win32 error the status maps to. An access denial is raised only once it outlasts a short grace, since
            a peer unlinking the file as it releases can make the open answer ``STATUS_ACCESS_DENIED`` for a moment.

        ÚopenN)Ú	read_onlyz1Lock file is a reparse point (symlink/junction): )#ÚsysÚauditr€   ÚO_RDWRÚO_CREATr    Ú_nt_openr'   ÚtimeÚ	monotonicr*   Úsleepr+   r&   r(   r)   r-   ÚRtlNtStatusToDosErrorrŒ   rH   ÚFormatErrorÚstriprX   r0   ÚGetFileInformationByHandlerl   rm   ÚCloseHandlern   rY   r   rj   Úopen_osfhandleÚO_NOINHERITr   )
r’   r”   r˜   ÚhandleÚstatusÚdeadlineÚwinerrorÚinforq   Úmsgs
             r>   r|   r|   ×   s  € õB 	Œ	�&˜$ ¥b¤iµ"´*Ñ&<Ñ=Ô=Ð=Ø�|Ñ+Ð+ˆ	Ý! $°)Ð<Ñ<Ô<‰ˆ�ØÕ*Ò*Ð*Ý”~Ñ'Ô'Õ*>Ñ>ˆHØÕ1Ò1Ð1µd´nÑ6FÔ6FÈÒ6QÐ6QÝ”
Õ/Ñ0Ô0Ð0Ý!)¨$¸)Ð!DÑ!DÔ!D‘�˜ð Õ1Ò1Ð1µd´nÑ6FÔ6FÈÒ6QÐ6Qð •_Ò$Ð$ØÕ3Õ5KÐLÐLÐLØ�tÝ×3Ò3°FÑ;Ô;ˆHÝ˜$¥Ô 2°8Ñ <Ô <× BÒ BÑ DÔ DÀdÈHÑUÔUÐUå*Ñ,Ô,ˆå×3Ò3°F½F¼LÈÑ<NÔ<NÑOÔOð 	'ÝÔ'Ñ)Ô)ˆCÝ×!Ò! &Ñ)Ô)Ð)Ý”/ #Ñ&Ô&Ð&ØÔ Õ#@Ñ@ð 	Ý×!Ò! &Ñ)Ô)Ð)ØLÀdÐLÐLˆCÝ˜#‘,”,Ðð	åÔ(¨µ´½R¼^Ñ1KÑLÔLÐLøÝð 	ð 	ð 	Ý×!Ò! &Ñ)Ô)Ð)Øð	øøøs   È+H8 È8&Ir˜   útuple[int, int]c               ót  — t          ¦   «         }t                               | t          j        |¦  «        dd¦  «        dz  }|t
          k    rd|fS 	 t          ¦   «         }t          j        t          ¦  «        |_        t          j	        |¦  «        |_
        t          |_        t          j        ¦   «         }t          ¦   «         }t                               t          j        |¦  «        t"          t          j        |¦  «        t          j        |¦  «        d|rt$          nt&          t(          t*          t,          dd¦  «        dz  }t                               t          j        |¦  «        ¦  «         n1# t                               t          j        |¦  «        ¦  «         w xY w|t
          k    rd|fS |j        pd|fS )a›  
        Open *path* through ``NtCreateFile`` and return ``(handle, status)``.

        ``RtlDosPathNameToNtPathName_U_WithStatus`` translates the Win32 path to the NT namespace, handling relative,
        drive, UNC and extended-length path forms as Win32 itself would, and allocates a buffer that
        ``RtlFreeUnicodeString`` releases. The handle is ``0`` unless the status is ``STATUS_SUCCESS``.
        Nl   ÿÿ r   )r2   r-   Ú'RtlDosPathNameToNtPathName_U_WithStatusrH   rl   r&   r@   Úsizeofr3   ÚpointerrB   r   rC   r   rG   rL   ÚNtCreateFiler   r   r   r   r   r   ÚRtlFreeUnicodeStringÚvalue)r’   r˜   Únt_namer©   Ú
attributesr¨   Ú	io_statuss          r>   r�   r�     s€  € õ "Ñ#Ô#ˆÝ×?Ò?ÀÅfÄlÐSZÑF[ÔF[Ð]aÐcgÑhÔhÐkuÑuˆØ•_Ò$Ð$Ø�f�9Ðð	?Ý+Ñ-Ô-ˆJÝ &¤Õ.@Ñ AÔ AˆJÔÝ$*¤N°7Ñ$;Ô$;ˆJÔ!Ý$9ˆJÔ!Ý”_Ñ&Ô&ˆFÝ(Ñ*Ô*ˆIå×#Ò#Ý”L Ñ(Ô(Ý#Ý”L Ñ,Ô,Ý”L Ñ+Ô+ØØ09ÐUÕ,Ð,Õ?UÝ*Ý!Ý#ØØñô ð ñð õ" ×'Ò'­¬°WÑ(=Ô(=Ñ>Ô>Ð>Ð>ø�F×'Ò'­¬°WÑ(=Ô(=Ñ>Ô>Ð>Ð>øøøØ•_Ò$Ð$Ø�f�9ÐØŒ|Ð ˜q &Ð(Ð(s   ÁC1E/ Å/.Fc                  ó"   — e Zd ZdZdd„Zdd„ZdS )rx   zRUses ``LockFileEx`` to hard lock a byte range of the lock file on Windows systems.rf   rs   c                ó   — t           ‚rz   ©ÚNotImplementedError©r‚   s    r>   r„   zWindowsFileLock._acquireF  ó   € Ý%Ð%r=   c                ó   — t           ‚rz   r»   r½   s    r>   rŽ   zWindowsFileLock._releaseI  r¾   r=   Nr�   r�   r<   r=   r>   rx   rx   C  sB   € € € € € Ø`Ð`ð	&ð 	&ð 	&ð 	&ð	&ð 	&ð 	&ð 	&ð 	&ð 	&r=   )rd   re   rf   rg   )rd   re   rf   rs   )r’   r“   r”   re   rf   r•   )r’   r“   r˜   rg   rf   r®   )PÚ
__future__r   r€   r™   rž   Ú
contextlibr   Úpathlibr   Útypingr   r   Ú_apir	   Ú_utilr
   r   ÚplatformrH   rj   r   r   Ú__annotations__r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r#   r%   r&   r'   r(   r)   r*   r+   ÚWinDLLr-   r0   Ú	Structurer2   r@   rL   rP   rX   ÚLONGr³   ÚrestyperI   rG   rV   Ú
c_longlongrF   rJ   Úargtypesr°   ÚLPCWSTRr´   r¡   r¥   ÚBOOLr¤   ri   ru   rr   rv   rx   r|   r�   Ú__all__r<   r=   r>   ú<module>rÑ      sG  ðØ "Ð "Ð "Ð "Ð "Ð "Ð "à 	€	€	€	Ø 
€
€
€
Ø €€€Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð Ø FÐ FÐ FÐ FÐ FÐ FÐ FÐ Fà„<�7ÒÑØ€M€M€MØ€M€M€MØÐÐÐÐÐà *€MÐ*Ð*Ð*Ñ*Ø!+€NÐ+Ð+Ð+Ñ+Ø)€LÐ)Ð)Ð)Ñ)Ø"/°.Ñ"@À<Ñ"O€OÐOÐOÐOÑOàð ð ð ð ñ ð !"€MÐ!Ð!Ð!Ñ!Ø+5ÐÐ5Ð5Ð5Ñ5Ø)3ÐÐ3Ð3Ð3Ñ3Ø0:Ð!Ð:Ð:Ð:Ñ:ð 1;Ð!Ð:Ð:Ð:Ñ:Ø+5ÐÐ5Ð5Ð5Ñ5Ø+5ÐÐ5Ð5Ð5Ñ5Ø"?ÐBZÑ"ZÐ]uÑ"u€OÐuÐuÐuÑuØ(2ÐÐ2Ð2Ð2Ñ2Ø$€LÐ$Ð$Ð$Ñ$ð .8ÐÐ7Ð7Ð7Ñ7Ø+5ÐÐ5Ð5Ð5Ñ5Ø(*ÐÐ*Ð*Ð*Ñ*ð
 #-€OÐ,Ð,Ð,Ñ,Ø(2ÐÐ2Ð2Ð2Ñ2Ø,6ÐÐ6Ð6Ð6Ñ6Ø)3ÐÐ3Ð3Ð3Ñ3ð *-ÐÐ,Ð,Ð,Ñ,Ø).ÐÐ.Ð.Ð.Ñ.à#0 6¤=°Ñ#9Ô#9€FÐ9Ð9Ð9Ñ9Ø&3 f¤m°JÈtÐ&TÑ&TÔ&T€IÐTÐTÐTÑTð
ð 
ð 
ð 
ð 
˜&Ô*ñ 
ô 
ð 
ð
ð 
ð 
ð 
ð 
˜VÔ-ñ 
ô 
ð 
ð
ð 
ð 
ð 
ð 
˜6Ô+ñ 
ô 
ð 
ð
ð 
ð 
ð 
ð 
�fÔ&ñ 
ô 
ð 
ð
ð 
ð 
ð 
ð 
 fÔ&6ñ 
ô 
ð 
ð #+¤-€FÔÔàˆŒ�x”Ñ'Ô'ØŒØˆŒÐ)Ñ*Ô*ØˆŒÐ'Ñ(Ô(ØˆŒ�vÔ(Ñ)Ô)ØŒØŒØŒØŒØŒØŒð$€FÔÔ ð >F¼]€FÔ2Ô:àÔØˆŒ�Ñ'Ô'ØŒØŒð	?€FÔ2Ô;ð +/€FÔÔ'Ø,:¨F¬N¸?Ñ,KÔ,KÐ+L€FÔÔ(Ø+3¬>€FÔ Ô(Ø-5¬]¨O€FÔ Ô)à&.¤oÐ%6€IÔÔ"Ø$,¤M€IÔÔ!Ø5=´_ÀnÀfÄnÐUpÑFqÔFqÐ4r€IÔ(Ô1Ø3;´=€IÔ(Ô0àŒØŒØŒØŒØŒØˆŒ�{Ñ#Ô#ð%€IÔÔ!ð $,¤=€IÔÔ àŒØŒØŒØŒØˆŒ�{Ñ#Ô#ð'€IÔÔ#ð &.¤]€IÔÔ"ð#ð #ð #ð #ð;ð ;ð ;ð ;ð&2ð &2ð &2ð &2ð &2˜,ñ &2ô &2ð &2ðP?ð ?ð ?ð ?ðB')ð ')ð ')ð ')ð ')ðV&ð &ð &ð &ð &˜,ñ &ô &ð &ð ð€€€r=   