
    siD                    :   S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSKJ	r	  SSK
Jr  SSKJr  SSKJr  SS	KJr  S
SKJrJrJr  \(       a  S
SKJrJr  \	" \5      rS rS rS r S         SS jjr SSS.       SS jjjr SSS.       SS jjjr g)zCommon Windows path utilities.    )annotationsN)	getLogger)Path)which)TYPE_CHECKING   )on_win   )nt_to_posixposix_to_ntresolve_paths)	PathsTypePathTypec                @    [         (       a  U R                  SS5      $ U $ )N/\r	   replacepaths    9lib/python3.13/site-packages/conda/common/path/windows.pywin_path_okr      s    &,f4<<T"6$6    c                @    [         (       a  U R                  SS5      $ U $ )Nr   z\\r   r   s    r   win_path_double_escaper      s    )/4<<f%9T9r   c                R    [         R                  " SSU 5      R                  SS5      $ )Nz	(\\(?! ))r   z:////z://)resubr   r   s    r   win_path_backoutr   "   s$     66,d+33GUCCr   c          	        U c  g [        U [        [        R                  45      (       a  U O
[	        U 5      n U (       d)  [        U [        [        R                  45      (       a  S$ S$ [
        (       a  Uc  SSKJn  UR                  nU(       a9  [        R                  nSn[        n[        R                  n[        R                  n	O8[        R                  nSn[        n[        R                  n[        R                  n	[        S5      n
U
(       a!  [        [!        U
5      R"                  S-  5      OSn[        U [        [        R                  45      (       a  [        U 5      OUR%                  ['        [        U 5      5      nS n [(        R*                  " XS	U/S
S
S
S9R,                  R/                  5       n[1        XU	5      nUc	  U" XU5      n[        U [        [        R                  45      (       a  U$ U(       d  g[	        URE                  U5      5      $ ! [2         a    [4        R7                  S5         Nv[(        R8                   ag  n[4        R;                  SUR<                  R>                  UUR,                  R/                  5       UR@                  R/                  5       5         S nANS nAf[B         a6  n[4        R;                  SUR<                  R>                  U5         S nAGN)S nAff = f)N.    )contextz--unixz	--windowsbashcygpathz--pathT)textcapture_outputcheckz<cygpath is not available, fallback to manual path conversionz_Unexpected cygpath error, fallback to manual path conversion
  %s: %s
  stdout: %s
  stderr: %szEUnexpected cygpath error, fallback to manual path conversion
  %s: %s)#
isinstancestrosPathLiketupler	   base.contextr$   target_prefixntpathpathsepr   	posixpathsepr   r   r   parentjoinmap
subprocessrunstdoutstripr   FileNotFoundErrorlogwarningCalledProcessErrorerror	__class____name__stderr	Exceptionsplit)pathsprefixcygdriveto_unixr$   from_pathsepcygpath_argcygpath_fallback
to_pathsepto_sepr%   r&   joined	convertederrs                  r   _path_torR   )   sR    }  R[['9::EeE bkk(:;;sCCv&.+&&~~&&&
 ((!&^^
 =D48c$t*##i/0iG ec2;;/00 	E
s3/  !IANN8V4	

 & 	6 ")@	$VX>	%#r{{+,,Y__Z011?  TRS(( 
		pMM""JJJJ	
 	
  
		TMM""	
 	

s+   2H K2:K2AJ//K2<+K--K2F)rH   c                   [        XUSS9$ )a]  Convert Windows paths to Unix paths.

.. note::
    Produces unexpected results when run on Unix.

Args:
    paths: The path(s) to convert.
    prefix: The (Windows path-style) prefix directory to use for the conversion.
          If not provided, no checks for prefix paths will be made.
    cygdrive: Whether to use the Cygwin-style drive prefix.
T)rG   rH   rI   rR   rF   rG   rH   s      r   win_path_to_unixrV      s    " E8TJJr   c                   [        XUSS9$ )ay  Convert Unix paths to Windows paths.

.. note::
    Produces unexpected results when run on Unix.

Args:
    paths: The path(s) to convert.
    prefix: The (Windows path-style) prefix directory to use for the conversion.
          If not provided, no checks for prefix paths will be made.
    cygdrive: Unused. Present to keep the signature consistent with `win_path_to_unix`.
F)rH   rI   rT   rU   s      r   unix_path_to_winrX      s    " EHeDDr   )N)
rF   PathType | PathsType | NonerG   PathType | NonerH   boolrI   r[   returnstr | tuple[str, ...] | None)rF   rY   rG   rZ   rH   r[   r\   r]   )!__doc__
__future__r   r1   r,   r3   r   r8   loggingr   pathlibr   shutilr   typingr   compatr	   _cygpathr   r   r    r   r   rB   r=   r   r   r   rR   rV   rX   r"   r   r   <module>rg      s   % "  	  	        = =%7:D #X2&X2X2 	X2
 X2 "X2z #K 	K&KK 	K
 "K, #E 	E&EE 	E
 "Er   