
    $TXg                         d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	m
Z
mZmZ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 ddlmZ ddlmZ ddlmZmZ  ee      Z d Z!ed        Z"ed        Z#d Z$y)z\Disk utility functions testing path properties (e.g., writable, hardlinks, softlinks, etc.).    )cache)	getLogger)W_OKaccess)basenamedirnameisdirisfilejoin)uuid4   )PREFIX_MAGIC_FILE)TRACE)expand)LinkType   )create_link)rm_rf)islinklexistsc                 X   t        |       } t        j                  t        d|        t        t	        |             r6t        |       }	 t        | d      }|j                          |st        |        yt        | t              S # t        $ r}t        j                  |       Y d }~yd }~ww xY w)Nzchecking path is writable %sza+TF)r   logr   r	   r   r   opencloser   OSErrordebugr   r   )pathpath_existedfhes       8lib/python3.12/site-packages/conda/gateways/disk/test.pyfile_path_is_writabler"      s    $<DGGE148WT]t}		dD!B
 HHJd dD!!  	IIaL	s   B 	B)
B$$B)c           
      h   t        |dt        |        dt        t                     d d        }t	        |       sJ |        t        |      sJ |       t        |      rt        |       t        |      rJ |       	 t        | |t        j                  d       t        |       }|rt        j                  t        d| |       nt        j                  t        d| |       |t        |       S # t        $ r* t        j                  t        d| |       Y t        |       yw xY w# t        |       w xY w)	N.tmp..   Tforcez hard link supported for %s => %sz'hard link IS NOT supported for %s => %sF)r   r   strr   r
   r	   r   r   r   r   hardlinkr   r   r   r   )source_filedest_dir	test_fileis_supporteds       r!   hardlink_supportedr/   *   s   Xx'<&=Qs57|BQ?O>PQRI+++?$H$?yiy!,9,! 	KH,=,=TJ!),,GGE={HUGG@+x 
 	i	  @+xXi	 	is%   =A%C. .%D!D$  D!!D$ $D1c                    t         j                  t        d| |       t        |dt        |       z         }t	        |       sJ |        t        |      sJ |       t        |      rJ |       	 t        | |t        j                  d       t        |      t        |       S # t        $ r Y t        |       yw xY w# t        |       w xY w)Nz*checking soft link capability for %s => %sr$   Tr'   F)r   r   r   r   r
   r	   r   r   r   softlinkr   r   r   )r+   r,   	test_paths      r!   softlink_supportedr3   E   s     GGE?hWXw+)>>?I+++?$H$?y!,9,!KH,=,=TJi  	i  i 	is$   ,'B 	B6(B9 5B66B9 9Cc                 4    t        t        | t                    S )N)r
   r   r   )prefixs    r!   is_conda_environmentr6   W   s    $v0122    N)%__doc__	functoolsr   loggingr   osr   r   os.pathr   r   r	   r
   r   uuidr   base.constantsr   common.constantsr   common.pathr   models.enumsr   creater   deleter   linkr   r   __name__r   r"   r/   r3   r6    r7   r!   <module>rG      sn    c    : :  / % ! $   !"(  4  "3r7   