
    DIe                        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mZ  ee          Zd Z ed          d             Z  ed          d             Z!d Z"dS )z\Disk utility functions testing path properties (e.g., writable, hardlinks, softlinks, etc.).    )	lru_cache)	getLogger)W_OKaccess)basenamedirnameisdirisfilejoin)uuid4   )PREFIX_MAGIC_FILE)expand)LinkType   )create_link)rm_rf)islinklexistsc                    t          |           } t                              d|            t          t	          |                     ryt          |           }	 t          | d          }|                                 |st          |            dS # t          $ r%}t          
                    |           Y d }~dS d }~ww xY wt          | t                    S )Nzchecking path is writable %sza+TF)r   logtracer	   r   r   opencloser   OSErrordebugr   r   )pathpath_existedfhes       8lib/python3.11/site-packages/conda/gateways/disk/test.pyfile_path_is_writabler"      s    $<<DII,d333WT]] "t}}		dD!!B
 HHJJJ d4  	 	 	IIaLLL55555	 dD!!!s   B 
B=B88B=N)maxsizec           
         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                              d| |           nt                              d| |           |t          |           S # t          $ r/ t                              d| |           Y t          |           dS 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_supportedr0   (   s   XQx'<'<QQs577||BQB?OQQRRI++++++??$$H$$$y iy!!,,9,,, 	KH,=TJJJJ!),,, 	XII8+xPPPPII?hWWW
 	i	    		;[(SSSi	 	is%   /A)D( (&E!E$  E!!E$ $E5c                    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          |           dS 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_supportedr4   A   s    II:KRRRXw+)>)>>??I++++++??$$H$$$y!!,,9,,,KH,=TJJJJi   	i    i 	is$   	+C 
C!C$  C!!C$ $C5c                 F    t          t          | t                              S )N)r
   r   r   )prefixs    r!   is_conda_environmentr7   S   s    $v011222    )#__doc__	functoolsr   loggingr   osr   r   os.pathr   r   r	   r
   r   uuidr   base.constantsr   common.pathr   models.enumsr   creater   deleter   linkr   r   __name__r   r"   r0   r4   r7    r8   r!   <module>rG      s   c b                     : : : : : : : : : : : : : :       / / / / / / ! ! ! ! ! ! $ $ $ $ $ $             ! ! ! ! ! ! ! !i" " "( 4  0 4  "3 3 3 3 3r8   