Ë
    ­Ó^jt>  ã                  ód	  — U 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	m
Z
 ddlmZ ddlmZmZ ej                   d	k(  �rad 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/<    ejV                  d0«      Z,d1ed2<    ejV                  d3d4¬5«      Z-d1ed6<    G d7„ d8ej\                  «      Z/ G d9„ d:ej\                  «      Z0 G d;„ d<ej\                  «      Z1 G d=„ d>ej\                  «      Z2 G d?„ d@ej\                  «      Z3ejh                  e,jj                  _6         ejn                  ejp                  «      ejr                   ejn                  e0«       ejn                  e1«       ejn                  ejt                  «      ejv                  ejv                  ejv                  ejv                  ejx                  ejv                  ge,jj                  _=        ejh                  e,j|                  _6        ej~                   ejn                  e/«      ejx                  ejx                  ge,j|                  _=        de,j€                  _6         ejn                  e/«      ge,j€                  _=        ejv                  e,j‚                  _6        ejh                  ge,j‚                  _=        ejp                  ge-j„                  _=        ej†                  e-j„                  _6        ejp                   ejn                  e3«      ge-jˆ                  _=        ej†                  e-jˆ                  _6        ejp                  ejr                  ejr                  ejr                  ejr                   ejn                  e2«      ge-jŠ                  _=        ej†                  e-jŠ                  _6        ejp                  ejr                  ejr                  ejr                   ejn                  e2«      ge-jŒ                  _=        ej†                  e-jŒ                  _6        dHdA„ZGdIdB„ZH G dC„ dDe«      ZIdJdE„ZJdKdF„ZKdDgZLy G dG„ dDe«      ZIdDgZLy)Lé    )Ú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_PENDINGÚntdllzFinal[ctypes.WinDLL]Ú_ntdllÚkernel32T)Úuse_last_errorÚ	_kernel32c                  ó^   — e Zd Zdej                  fdej                  fdej
                  ffZy)Ú_UNICODE_STRINGÚLengthÚMaximumLengthÚBufferN)Ú__name__Ú
__module__Ú__qualname__r   ÚUSHORTÚLPWSTRÚ_fields_© ó    ú\/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/filelock/_windows.pyr0   r0   8   s-   „ à�x—‘Ð'Ø˜hŸo™oÐ.Ø�x—‘Ð'ð
‰r;   r0   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
y)Ú_OBJECT_ATTRIBUTESr1   ÚRootDirectoryÚ
ObjectNameÚ
AttributesÚSecurityDescriptorÚSecurityQualityOfServiceN)r4   r5   r6   r   ÚULONGÚHANDLEÚctypesÚPOINTERr0   Úc_void_pr9   r:   r;   r<   r>   r>   ?   sX   „ à�x—~‘~Ð&Ø˜hŸo™oÐ.Ø˜>˜6Ÿ>™>¨/Ó:Ð;Ø˜8Ÿ>™>Ð*Ø! 6§?¡?Ð3Ø'¨¯©Ð9ð
‰r;   r>   c                  óD   — e Zd Zdej                  fdej                  ffZy)Ú_IO_STATUS_BLOCKÚStatusÚInformationN)r4   r5   r6   rF   rH   r9   r:   r;   r<   rJ   rJ   I   s!   „ à�v—‘Ð'Ø˜FŸO™OÐ,ð
‰r;   rJ   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fZy)Ú_OVERLAPPEDÚInternalÚInternalHighÚOffsetÚ
OffsetHighÚhEventN)	r4   r5   r6   rF   rH   r   ÚDWORDrE   r9   r:   r;   r<   rN   rN   O   sE   „ à˜Ÿ™Ð)Ø˜VŸ_™_Ð-Ø�x—~‘~Ð&Ø˜8Ÿ>™>Ð*Ø�x—‘Ð'ð
‰r;   rN   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y)Ú_BY_HANDLE_FILE_INFORMATIONÚdwFileAttributesÚftCreationTimeÚftLastAccessTimeÚftLastWriteTimeÚdwVolumeSerialNumberÚnFileSizeHighÚnFileSizeLowÚnNumberOfLinksÚnFileIndexHighÚnFileIndexLowN)r4   r5   r6   r   rT   ÚFILETIMEr9   r:   r;   r<   rV   rV   X   s‡   „ à §¡Ð0Ø˜x×0Ñ0Ð1Ø ×!2Ñ!2Ð3Ø × 1Ñ 1Ð2Ø# X§^¡^Ð4Ø˜hŸn™nÐ-Ø˜XŸ^™^Ð,Ø˜xŸ~™~Ð.Ø˜xŸ~™~Ð.Ø˜hŸn™nÐ-ð
‰r;   rV   c           
     ó  — t        «       }t        t        z  }t        j	                  t        j                  | «      |dddt        j                  |«      «      ryt        j                  «       }|t        k(  ryt        j                  |«      ‚)Nr   r   TF)rN   r#   r!   r.   Ú
LockFileExÚmsvcrtÚget_osfhandlerF   ÚbyrefÚget_last_errorr%   ÚWinError)ÚfdÚ
overlappedÚflagsÚerrs       r<   Ú_lock_fd_nonblockingrm   –   so   € ô !“]ˆ
Ü(Ô+EÑEˆÜ×Ñ¤× 4Ñ 4°RÓ 8¸%ÀÀAÀqÌ&Ï,É,ÐWaÓJbÔcØÜ×#Ñ#Ó%ˆØÔ'Ò'Øä�o‰o˜cÓ"Ð"r;   c           	     óä   — t        «       }t        j                  t        j                  | «      dddt        j                  |«      «      s't        j                  t        j                  «       «      ‚y )Nr   r   )	rN   r.   ÚUnlockFileExrd   re   rF   rf   rh   rg   )ri   rj   s     r<   Ú
_unlock_fdrp   ¤   sR   € Ü “]ˆ
ä×%Ñ%¤f×&:Ñ&:¸2Ó&>ÀÀ1ÀaÌÏÉÐV`ÓIaÔbÜ—/‘/¤&×"7Ñ"7Ó"9Ó:Ð:ð cr;   c                  ó    — e Zd ZdZdd„Zdd„Zy)Ú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.
        c                óZ  — t        | j                  «       t        | j                  «       t        | j                  | j	                  «       «      }|€y 	 t        |«      }|r| j                  |«       |st        j                  |«       y y # t        $ r t        j                  |«       ‚ w xY w©N)
r   Ú	lock_filer
   Ú_open_non_reparse_fdÚ
_open_moderm   Ú_mark_descriptor_ownedÚBaseExceptionÚosÚclose)Úselfri   Úlockeds      r<   Ú_acquirezWindowsFileLock._acquire³   s�   € Ü& t§~¡~Ô6Ü# D§N¡NÔ3ô & d§n¡n°d·o±oÓ6GÓHˆBØˆzØðÜ-¨bÓ1�ÙØ×/Ñ/°Ô3ñ Ü—‘˜•ð øô !ò Ü—‘˜”Øðús   ÁB
 Â
 B*c                óH  — t        d| j                  j                  «      }t        |«       | j	                  «        | j                  |d¬«       | j                  s<t        t        «      5  t        | j                  «      j                  «        d d d «       y y # 1 sw Y   y xY w)NÚintF)Údefault_suppresses)r   Ú_contextÚlock_file_fdrp   Ú_mark_descriptor_releasedÚ_close_released_fdÚ_preserve_lock_filer   ÚOSErrorr   ru   Úunlink)r|   ri   s     r<   Ú_releasezWindowsFileLock._releaseÆ   s…   € Ü�e˜TŸ]™]×7Ñ7Ó8ˆBô �rŒNØ×*Ñ*Ô,Ø×#Ñ# B¸5Ð#ÔAØ×+Ò+ÜœgÓ&ñ 2Ü˜Ÿ™Ó(×/Ñ/Ô1÷2ð 2ð ,÷2ð 2ús   Á*$BÂB!N©ÚreturnÚNone©r4   r5   r6   Ú__doc__r~   r‰   r:   r;   r<   rr   rr   ª   s   „ ñ	ó	ô&
	2r;   rr   c                ó\  — t        j                  d| dt        j                  t        j                  z  «       t        | |t        z   ¬«      \  }}|t        k7  rS|t        t        hv ryt        j                  |«      }t        dt        j                  |«      j                  «       | |«      ‚t!        «       }t"        j%                  |t        j&                  |«      «      s>t        j(                  «       }t"        j+                  |«       t        j,                  |«      ‚|j.                  t0        z  r%t"        j+                  |«       d| › �}t        |«      ‚	 t3        j4                  |t        j                  t        j6                  z  «      S # t8        $ r t"        j+                  |«       ‚ 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.

        ÚopenN)Ú	read_onlyz1Lock file is a reparse point (symlink/junction): )ÚsysÚauditrz   ÚO_RDWRÚO_CREATÚ_nt_openr    r&   r(   r)   r+   ÚRtlNtStatusToDosErrorr‡   rF   ÚFormatErrorÚstriprV   r.   ÚGetFileInformationByHandlerf   rg   ÚCloseHandlerh   rW   r   rd   Úopen_osfhandleÚO_NOINHERITry   )ÚpathÚmodeÚhandleÚstatusÚwinerrorÚinforl   Úmsgs           r<   rv   rv   Ò   sO  € ô@ 	�	‰	�&˜$ ¤b§i¡i´"·*±*Ñ&<Ô=Ü! $°d¼\Ñ6IÐ2IÔJ‰ˆ�Ø”_Ò$ØÔ3Ô5KÐLÑLØÜ×3Ñ3°FÓ;ˆHÜ˜$¤× 2Ñ 2°8Ó <× BÑ BÓ DÀdÈHÓUÐUä*Ó,ˆä×3Ñ3°F¼F¿L¹LÈÓ<NÔOÜ×'Ñ'Ó)ˆCÜ×!Ñ! &Ô)Ü—/‘/ #Ó&Ð&Ø× Ñ Ô#@Ò@Ü×!Ñ! &Ô)ØEÀdÀVÐLˆCÜ˜#“,Ðð	ä×(Ñ(¨´·±¼R¿^¹^Ñ1KÓLÐLøÜò 	Ü×!Ñ! &Ô)Øð	ús   Å4F Æ F+c               ó:  — t        «       }t        j                  | t        j                  |«      dd«      dz  }|t
        k7  rd|fS 	 t        «       }t        j                  t        «      |_        t        j                  |«      |_
        t        |_        t        j                  «       }t        «       }t        j!                  t        j                  |«      t"        t        j                  |«      t        j                  |«      d|rt$        nt&        t(        t*        t,        dd«      dz  }t        j/                  t        j                  |«      «       |t
        k7  rd|fS |j0                  xs d|fS # t        j/                  t        j                  |«      «       w xY w)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   )r0   r+   Ú'RtlDosPathNameToNtPathName_U_WithStatusrF   rf   r&   r>   Úsizeofr1   Úpointerr@   r   rA   r   rE   rJ   ÚNtCreateFiler   r   r   r   r   r   ÚRtlFreeUnicodeStringÚvalue)rž   r‘   Únt_namer¡   Ú
attributesr    Ú	io_statuss          r<   r–   r–     sK  € ô "Ó#ˆÜ×?Ñ?ÀÄfÇlÁlÐSZÓF[Ð]aÐcgÓhÐkuÑuˆØ”_Ò$Ø�f�9Ðð	?Ü+Ó-ˆJÜ &§¡Ô.@Ó AˆJÔÜ$*§N¡N°7Ó$;ˆJÔ!Ü$9ˆJÔ!Ü—_‘_Ó&ˆFÜ(Ó*ˆIä×#Ñ#Ü—L‘L Ó(Ü#Ü—L‘L Ó,Ü—L‘L Ó+ØÙ09Õ,Ô?UÜ*Ü!Ü#ØØóð ñð ô" ×'Ñ'¬¯©°WÓ(=Ô>Ø”_Ò$Ø�f�9ÐØ�|‰|Ò ˜q &Ð(Ð(øô ×'Ñ'¬¯©°WÓ(=Õ>ús   ÁC"E0 Å0*Fc                  ó    — e Zd ZdZdd„Zdd„Zy)rr   zRUses ``LockFileEx`` to hard lock a byte range of the lock file on Windows systems.c                ó   — t         ‚rt   ©ÚNotImplementedError©r|   s    r<   r~   zWindowsFileLock._acquire:  ó   € Ü%Ð%r;   c                ó   — t         ‚rt   r±   r³   s    r<   r‰   zWindowsFileLock._release=  r´   r;   NrŠ   r�   r:   r;   r<   rr   rr   7  s   „ Ù`ó	&ô	&r;   )ri   r€   r‹   Úbool)ri   r€   r‹   rŒ   )rž   ÚstrrŸ   r€   r‹   z
int | None)rž   r·   r‘   r¶   r‹   ztuple[int, int])MÚ
__future__r   rz   r’   Ú
contextlibr   Úpathlibr   Útypingr   r   Ú_apir	   Ú_utilr
   r   ÚplatformrF   rd   r   r   Ú__annotations__r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r#   r%   r&   r'   r(   r)   ÚWinDLLr+   r.   Ú	Structurer0   r>   rJ   rN   rV   ÚLONGr©   ÚrestyperG   rE   rT   Ú
c_longlongrD   rH   Úargtypesr¦   ÚLPCWSTRrª   r—   r›   ÚBOOLrš   rc   ro   rm   rp   rr   rv   r–   Ú__all__r:   r;   r<   ú<module>rÉ      sA  ðÞ "ã 	Û 
Ý Ý ß å ß Fà‡<�<�7ÓÛÛÝà *€M�:Ó*Ø!+€N�JÓ+Ø)€L�*Ó)Ø"/°.Ñ"@À<Ñ"O€O�ZÓOàð ˜Jó ð !"€M�:Ó!Ø+5Ð˜jÓ5Ø)3Ð˜JÓ3Ø0:Ð! :Ó:ð 1;Ð! :Ó:Ø+5Ð˜jÓ5Ø+5Ð˜jÓ5Ø"?ÐBZÑ"ZÐ]uÑ"u€O�ZÓuØ(2Ð˜:Ó2Ø$€L�*Ó$ð .8Ð 
Ó7Ø+5Ð˜jÓ5Ø(*Ð˜:Ó*ð
 #-€O�ZÓ,Ø(2Ð˜:Ó2Ø,6Ð˜zÓ6Ø)3Ð˜JÓ3à#0 6§=¡=°Ó#9€FÐ Ó9Ø&3 f§m¡m°JÈtÔ&T€IÐ#ÓTô
˜&×*Ñ*ô 
ô
˜V×-Ñ-ô 
ô
˜6×+Ñ+ô 
ô
�f×&Ñ&ô 
ô
 f×&6Ñ&6ô 
ð #+§-¡-€F×ÑÔàˆ�‰�x—‘Ó'Ø�‰Øˆ�‰Ð)Ó*Øˆ�‰Ð'Ó(Øˆ�‰�v×(Ñ(Ó)Ø�‰Ø�‰Ø�‰Ø�‰Ø�‰Ø�‰ð$€F×ÑÔ ð >F¿]¹]€F×2Ñ2Ô:à×ÑØˆ�‰�Ó'Ø�‰Ø�‰ð	?€F×2Ñ2Ô;ð +/€F×ÑÔ'Ø,:¨F¯N©N¸?Ó,KÐ+L€F×ÑÔ(Ø+3¯>©>€F× Ñ Ô(Ø-5¯]©]¨O€F× Ñ Ô)à&.§o¡oÐ%6€I×ÑÔ"Ø$,§M¡M€I×ÑÔ!Ø5=·_±_ÀnÀfÇnÁnÐUpÓFqÐ4r€I×(Ñ(Ô1Ø3;·=±=€I×(Ñ(Ô0à�‰Ø�‰Ø�‰Ø�‰Ø�‰Øˆ�‰�{Ó#ð%€I×ÑÔ!ð $,§=¡=€I×ÑÔ à�‰Ø�‰Ø�‰Ø�‰Øˆ�‰�{Ó#ð'€I×ÑÔ#ð &.§]¡]€I×ÑÔ"ó#ó;ô&2˜,ô &2óP8ót')ðl ð�ô&˜,ô &ð ð�r;   