
    g                        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(  rd dl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win32c                       e Zd ZdZddZddZy)WindowsFileLockWUses the :func:`msvcrt.locking` function to hard lock the lock file on Windows systems.c                h   t        | j                         t        | j                         t        j                  t        j
                  z  t        j                  z  }	 t        j                  | 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Nr   )r   	lock_filer
   osO_RDWRO_CREATO_TRUNCopen_contextmodemsvcrtlockingLK_NBLCKlock_file_fdOSErrorcloseerrnor   )selfflagsfd	exceptions       F/var/www/openai/venv/lib/python3.12/site-packages/filelock/_windows.py_acquirezWindowsFileLock._acquire   s    &t~~6#DNN3		**** 
4WWT^^UDMM4F4FG
4NN2v: 24DMM.  HHRL &0 1  ??f, -s0   5D
 %C 	D)DD
	D1D,,D1c                p   t        t        | 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r   )r   intr   r   r   r   LK_UNLCKr   r   r   r   r   r   unlink)r!   r#   s     r%   _releasezWindowsFileLock._release*   sl    c4==556B)-DMM&NN2v2HHRL'"T^^$++- #""s   ?$B,,B5NreturnNone__name__
__module____qualname____doc__r&   r+        r%   r   r      s    e	4.	.r5   r   c                       e Zd ZdZddZddZy)r   r   c                    t         NNotImplementedErrorr!   s    r%   r&   zWindowsFileLock._acquire8       %%r5   c                    t         r8   r9   r;   s    r%   r+   zWindowsFileLock._release;   r<   r5   Nr,   r/   r4   r5   r%   r   r   5   s    e	&	&r5   )
__future__r   r   sys
contextlibr   r    r   pathlibr   typingr   _apir	   _utilr
   r   platformr   r   __all__r4   r5   r%   <module>rG      s`    " 	 
      F<<7!., !.` &, & r5   