+
    Pj^                    z    ^ RI Ht ^ RIt^ RIt^ RIt^ RIt^ RIHtHt ^ RI	H
t
 R R ltR R ltR	 R
 lt. ROtR# )    )annotationsN)EACCESEISDIR)Pathc                    V ^8  d   QhRRRR/# )   filenamestrreturnNone )formats   "g/Users/ahmed/devFolder/Ultron/claude-voice/gateway/.venv/lib/python3.14/site-packages/filelock/_util.py__annotate__r      s     D D D D    c                    \         P                  ! V 4      pTP                  \        P
                  ,          '       g   \        \        RT 4      h\        P                  ! TP                  4      '       d8   \        P                  R8X  d   \        \        RT 4      h\        \        RT 4      hR#   \         d     R# i ; i)a  
Raise an exception if attempting to open the file for writing would fail.

Separates files that can never be written from files that are writable but currently locked.

:param filename: file to check

:raises OSError: as if the file was opened for writing.

NzPermission deniedwin32zIs a directory)oslstatOSErrorst_modestatS_IWUSRPermissionErrorr   S_ISDIRsysplatformIsADirectoryErrorr   )r	   	file_stats   & r   raise_on_not_writable_filer       s    
 HHX&	 ,,f&98DD||I%%&&<<7"!&*=xHH(8(CC '  s   B/ /B>=B>c                    V ^8  d   QhRRRR/# )r   r	   z
Path | strr   r   r   )r   s   "r   r   r   +   s     = =j =T =r   c                R    \        V 4      P                  P                  RRR7       R# )zd
Ensure the directory containing the file exists (create it if necessary).

:param filename: file.

T)parentsexist_okN)r   parentmkdir)r	   s   &r   ensure_directory_existsr'   +   s!     	Nt<r   c               (    V ^8  d   QhRRRRRRRR/# )	r   	lock_filer
   mtime_beforefloat
ino_beforeintr   r   r   )r   s   "r   r   r   5   s(     # #s #% #S #T #r   c                h   V  R\         P                  ! 4        R\        P                  ! ^4       2p\	        V 4      P                  V4        \         P                  ! V4      pTP                  T8  g   TP                  T8w  d   R# \	        T4      P                  4        R#   \         d     R# i ; i)uO  
Atomically break a stale lock file that was judged stale at modification time *mtime_before*.

The file is renamed to a process-private name before being unlinked, so two processes breaking the same lock
cannot delete each other's work (only one rename of a given inode succeeds; the loser gets ``OSError``). After the
rename the file is re-checked: a newer modification time, or a different inode than *ino_before*, means a peer
recreated the lock between the stale decision and the rename, so we grabbed a live file and must abort, leaving the
renamed file in place rather than rolling back (a rollback rename is itself racy — same trade-off as the soft
read/write marker break). The inode check matters because filesystems with coarse modification-time granularity
(NFS, FAT) can give a same-second recreation the old mtime, so mtime alone would not catch it and a live lock would
be unlinked; the inode is the reliable identity, mirroring the token re-check in the soft read/write marker break.
``lstat`` is used so a hostile symlink swapped in after the decision is not followed.

The break name carries a random token so it is unguessable and unique per attempt. Without it two breakers in the
same process share ``<lock>.break.<pid>``, and a second break can rename a freshly recreated live lock onto that
path in the window between the re-verify ``lstat`` above and the ``unlink`` below, so we would delete a live lock
the inode check just approved. A private name means nobody else can target our break path, matching the soft
read/write marker break.

:param lock_file: path to the lock file to break.
:param mtime_before: modification time observed when the lock was judged stale.
:param ino_before: inode number observed when the lock was judged stale.

:raises OSError: if the rename fails (e.g. the file vanished or is not owned in a sticky directory).

z.break..N)r   getpidsecrets	token_hexr   renamer   r   st_mtimest_inounlink)r)   r*   r,   
break_pathst_afters   &&&  r   break_lock_filer9   5   s    6 ;gbiik]!G4E4Eb4I3JKJO:&88J' <'8??j+H	  s   B" "B10B1)r9   r'   r    )
__future__r   r   r1   r   r   errnor   r   pathlibr   r    r'   r9   __all__r   r   r   <module>r>      s3    " 	   
   D@=#Lr   