§
    ‰+j*  ã                  óf   — d dl mZ d dlZd dlZd dlZd dlmZmZ d dlm	Z	 dd	„Z
dd„Zdd„Zg d¢ZdS )é    )ÚannotationsN)ÚEACCESÚEISDIR)ÚPathÚfilenameÚstrÚreturnÚNonec                ól  — 	 t          j        | ¦  «        }n# t          $ r Y dS w xY w|j        dk    r|j        t          j        z  st          t          d| ¦  «        ‚t          j        |j        ¦  «        r>t          j
        dk    rt          t          d| ¦  «        ‚t          t          d| ¦  «        ‚dS dS )a4  
    Raise an exception if attempting to open the file for writing would fail.

    This is done so files that will never be writable can be separated from files that are writable but currently
    locked.

    :param filename: file to check

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

    Nr   zPermission deniedÚwin32zIs a directory)ÚosÚstatÚOSErrorÚst_mtimeÚst_modeÚS_IWUSRÚPermissionErrorr   ÚS_ISDIRÚsysÚplatformÚIsADirectoryErrorr   )r   Ú	file_stats     úR/home/wildlama/visual-decline/.venv/lib/python3.11/site-packages/filelock/_util.pyÚraise_on_not_writable_filer   
   sÏ   € ðÝ”G˜HÑ%Ô%ˆ	ˆ	øÝð ð ð Øˆˆðøøøð Ô˜QÒÐØÔ!¥D¤LÑ0ð 	IÝ!¥&Ð*=¸xÑHÔHÐHåŒ<˜	Ô)Ñ*Ô*ð 	LÝŒ|˜wÒ&Ð&å%¥fÐ.AÀ8ÑLÔLÐLõ (­Ð0@À(ÑKÔKÐKð Ðð	Lð 	Ls   ‚ —
%¤%ú
Path | strc                óX   — t          | ¦  «        j                             dd¬¦  «         dS )zp
    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„NÔ×Ò¨°tÐÑ<Ô<Ð<Ð<Ð<ó    Ú	lock_fileÚmtime_beforeÚfloatc                ó$  — | › dt          j        ¦   «         › }t          | ¦  «                             |¦  «         	 t          j        |¦  «        j        }n# t          $ r Y dS w xY w||k    rdS t          |¦  «                             ¦   «          dS )u  
    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 modification time is re-checked: a value newer than *mtime_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). ``lstat`` is used so a hostile symlink swapped in after the decision is not followed.

    :param lock_file: path to the lock file to break.
    :param mtime_before: modification time 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   Úgetpidr   ÚrenameÚlstatr   r   Úunlink)r#   r$   Ú
break_pathÚmtime_afters       r   Úbreak_lock_filer-   2   s¢   € ð" Ð3Ð3¥b¤i¡k¤kÐ3Ð3€JÝˆO„O×Ò˜:Ñ&Ô&Ð&ðÝ”h˜zÑ*Ô*Ô3ˆˆøÝð ð ð Øˆˆðøøøà\Ò!Ð!ØˆÝˆÑÔ×ÒÑÔÐÐÐs   ¼A Á
A$Á#A$)r-   r!   r   )r   r   r	   r
   )r   r   r	   r
   )r#   r   r$   r%   r	   r
   )Ú
__future__r   r   r   r   Úerrnor   r   Úpathlibr   r   r!   r-   Ú__all__© r"   r   ú<module>r3      s±   ðØ "Ð "Ð "Ð "Ð "Ð "à 	€	€	€	Ø €€€Ø 
€
€
€
Ø  Ð  Ð  Ð  Ð  Ð  Ð  Ð  Ø Ð Ð Ð Ð Ð ðLð Lð Lð Lð<=ð =ð =ð =ðð ð ð ð8ð ð €€€r"   