
    Rh                         d Z ddlZddlZg dZd Zd Zd Zd Zd Zd	 Z	d
 Z
d Zd Zd Zd Zd Zd Zd Zej&                   G d d             Zy)z
Path operations common to more than one OS
Do not use directly.  The OS specific modules import the appropriate
functions from this module themselves.
    N)commonprefixexistsgetatimegetctimegetmtimegetsizeisdirisfileislinksamefilesameopenfilesamestatALLOW_MISSINGc                 Z    	 t        j                  |        y# t        t        f$ r Y yw xY w)zDTest whether a path exists.  Returns False for broken symbolic linksFT)osstatOSError
ValueError)paths    "/usr/lib/python3.12/genericpath.pyr   r      s0    
  Z  s    **c                     	 t        j                  |       }t        j                  |j
                        S # t        t        f$ r Y yw xY w)z%Test whether a path is a regular fileF)r   r   r   r   S_ISREGst_moder   sts     r   r
   r
      sB    WWT] <<

## Z     6 AAc                     	 t        j                  |       }t        j                  |j
                        S # t        t        f$ r Y yw xY w)z<Return true if the pathname refers to an existing directory.F)r   r   r   r   S_ISDIRr   )sr   s     r   r	   r	   '   sB    WWQZ <<

## Z  r   c                     	 t        j                  |       }t        j                  |j                        S # t        t        t        f$ r Y yw xY w)z&Test whether a path is a symbolic linkF)r   lstatr   r   AttributeErrorr   S_ISLNKr   r   s     r   r   r   3   sD    XXd^ <<

## Z0 s   6 AAc                 @    t        j                  |       j                  S )z1Return the size of a file, reported by os.stat().)r   r   st_sizefilenames    r   r   r   <   s    778$$$    c                 @    t        j                  |       j                  S )zCReturn the last modification time of a file, reported by os.stat().)r   r   st_mtimer&   s    r   r   r   A       778%%%r(   c                 @    t        j                  |       j                  S )z=Return the last access time of a file, reported by os.stat().)r   r   st_atimer&   s    r   r   r   F   r+   r(   c                 @    t        j                  |       j                  S )zAReturn the metadata change time of a file, reported by os.stat().)r   r   st_ctimer&   s    r   r   r   K   r+   r(   c                     | syt        | d   t        t        f      s#t        t        t        j
                  |             } t        |       }t        |       }t        |      D ]  \  }}|||   k7  s|d| c S  |S )zGGiven a list of pathnames, returns the longest common leading component r   N)	
isinstancelisttuplemapr   fspathminmax	enumerate)ms1s2ics        r   r   r   Q   sv    R
 adT5M*#bii#$	QB	QB" 11:bq6M Ir(   c                 j    | j                   |j                   k(  xr | j                  |j                  k(  S )z5Test whether two stat buffers reference the same file)st_inost_dev)r;   r<   s     r   r   r   c   s,    II" #II"$r(   c                 n    t        j                  |       }t        j                  |      }t        ||      S )zTest whether two pathnames reference the same actual file or directory

    This is determined by the device number and i-node number and
    raises an exception if an os.stat() call on either pathname fails.
    )r   r   r   )f1f2r;   r<   s       r   r   r   j   s+     
B	BBr(   c                 n    t        j                  |       }t        j                  |      }t        ||      S )z:Test whether two open file objects reference the same file)r   fstatr   )fp1fp2r;   r<   s       r   r   r   w   s)    	#B	#BBr(   c                     | j                  |      }|r| j                  |      }t        ||      }| j                  |      }||kD  r*|dz   }||k  r | ||dz    |k7  r
| d| | |d fS |dz  }||k  r | | dd fS )zSplit the extension from a pathname.

    Extension is everything from the last dot to the end, ignoring
    leading dots.  Returns "(root, ext)"; ext may be empty.   Nr   )rfindr8   )psepaltsepextsepsepIndexaltsepIndexdotIndexfilenameIndexs           r   	_splitextrT      s     wws|Hggfox-wwvH( 1h&}Q/69(|Qxy\11QM h&
 ae8Or(   c                     dx}}|D ]L  }t        |t              rd}t        |t              rd})t        |  d|j                  j
                        d  |r|rt        d      d y y )NFTz;() argument must be str, bytes, or os.PathLike object, not z.Can't mix strings and bytes in path components)r2   strbytes	TypeError	__class____name__)funcnameargshasstrhasbytesr   s        r   _check_arg_typesr_      s    FX [aF5!Hxj )778{{7K7K6NP QVZ[[ (HItS vr(   c                       e Zd ZdZd Zd Zy)r   z$Special value for use in realpath().c                      y)Nzos.path.ALLOW_MISSING selfs    r   __repr__zALLOW_MISSING.__repr__   s    &r(   c                 .    | j                   j                  S )N)rY   rZ   rc   s    r   
__reduce__zALLOW_MISSING.__reduce__   s    ~~&&&r(   N)rZ   
__module____qualname____doc__re   rg   rb   r(   r   r   r      s    .''r(   r   )rj   r   r   __all__r   r
   r	   r   r   r   r   r   r   r   r   r   rT   r_   object__new__r   rb   r(   r   <module>rn      s}   
 
 ($$$%
&
&
&$$.T ' ' 'r(   