o
    ei                     @  s   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mZ ejdkr_d dlZd dlZd d	lmZ d
ZdZejdddZejgej_ejej_dddZG dd de	ZnG dd de	ZdgZdS )    )annotationsN)EACCES)cast   )BaseFileLock)ensure_directory_existsraise_on_not_writable_filewin32)wintypesi   l    kernel32T)use_last_errorpathstrreturnboolc                 C  sB   t | }|tkrt }|dkrdS |dkrdS dS t|t@ 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_errorr   FILE_ATTRIBUTE_REPARSE_POINT)r   attrserr r   O/home/ubuntu/transcripts/venv/lib/python3.10/site-packages/filelock/_windows.py_is_reparse_point   s   
r   c                   @  $   e Zd ZdZd	ddZd	ddZdS )
WindowsFileLockWUses the :func:`msvcrt.locking` function to hard lock the lock file on Windows systems.r   Nonec              
   C  s   t | j t| j t| jrd| j }t|tjtjB }zt| j|| 	 }W n tyD } z|j
tkr9 W Y d }~d S d }~ww z
t|tjd W n tym } zt| |j
tkrb W Y d }~d S d }~ww || j_d S )Nz1Lock file is a reparse point (symlink/junction): r   )r   	lock_filer   r   OSErrorosO_RDWRO_CREATopen
_open_modeerrnor   msvcrtlockingLK_NBLCKclose_contextlock_file_fd)selfmsgflagsfd	exceptionr   r   r   _acquire3   s6   





WindowsFileLock._acquirec                 C  s4   t d| jj}d | j_t|tjd t| d S )Nintr   )r   r.   r/   r*   r+   LK_UNLCKr$   r-   )r0   r3   r   r   r   _releaseP   s   WindowsFileLock._releaseNr   r!   __name__
__module____qualname____doc__r5   r9   r   r   r   r   r   0   s    
r   c                   @  r   )
r   r    r   r!   c                 C     t NNotImplementedErrorr0   r   r   r   r5   [      r6   c                 C  rA   rB   rC   rE   r   r   r   r9   ^   rF   r:   Nr;   r<   r   r   r   r   r   X   s    
)r   r   r   r   )
__future__r   r$   sysr)   r   typingr   _apir   _utilr   r   platformr   r*   r
   r   r   WinDLLr   LPCWSTRr   argtypesDWORDrestyper   r   __all__r   r   r   r   <module>   s*    


(