
    Mh                        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mZmZmZmZmZmZ d dlmZmZmZmZ e
j        Zej        Ze
j        Zej        Z G d de          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)dS )    )unicode_literalsN)	text_type)preprocess_paths)windll	Structurebyrefc_uintcreate_unicode_buffer	addressofGetLastErrorFormatError)HWNDUINTLPCWSTRBOOLc            	       B    e Zd ZdefdefdefdefdefdefdefdefgZd	S )
SHFILEOPSTRUCTWhwndwFuncpFrompTofFlagsfAnyOperationsAbortedhNameMappingslpszProgressTitleN)	__name__
__module____qualname__r   r   r   r	   r   _fields_     U/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/send2trash/win/legacy.pyr   r       sS        		$	'		6	 $'	&!	g&	HHHr!   r                  @   i   c           
          i ddddddddddd	dd
dddddddddddddddddddddddddddddd}|                     | |           S )Nq   P   r   W   s   t   u   i  v   x      y   o   z   |      }   ~                        i        )            r;   i  i   it  )get)resultresultss     r"   convert_sh_file_opt_resultrK   9   s   dd 	d 	d	
 	e 	d 	d 	d 	d 	d 	d 	d 	d 	d 	d  	d!" 	e#$ 3  G8 ;;vv&&&r!   c                     d| }}|                      |          s+|                      d          rd}|| dd         z   }n || z   }n|                      |dz             rd}||fS )zGuess the long-path prefix based on the kind of *path*.
    Local paths (C:\folder\file.ext) and UNC names (\\server\folder\file.ext)
    are handled.

    Return a tuple of the long-path prefix and the prefixed path.
    z\\?\z\\\\?\UNCr#   NzUNC\)
startswith)pathprefix	long_paths      r"   prefix_and_pathrR   \   s     "4IF??6"" 
??6"" 	&!Fabb)II II	')	*	* 9r!   c                 p    | dk    rd|t          |           d         z   S |t          |           d         S )zGuess the correct path to pass to the SHFileOperationW() call.
    The long-path prefix must be removed, so we should take care of
    different long-path prefixes.
    rM   \N)len)rP   rO   s     r"   get_awaited_path_from_prefixrV   t   s@    
  d3v;;==)))Fr!   c                    t          |           \  }}t          |d d          }|s,t                      }t          |t	          |          |          t          |          }t          |||           t          ||j                  S )Nr   )rR   GetShortPathNameWr   WindowsErrorr   r
   rV   value)	long_namerP   rQ   buf_sizeerr_nooutputs         r"   get_short_path_namer_      s    '	22FI D!44H  C6;v#6#6	BBB"8,,Fi222'===r!   c                    t          |           } | sd S d | D             } d | D             } d | D             } t                      }d|_        t          |_        t          d                    |                     }d                    |           }t          |t          |          dz             }t          t          |                    |_
        d |_        t          t          z  t          z  t          z  |_        d|_        d|_        d |_        t)          t+          |                    }|r.t-          |          }t/          d t1          |          | |          d S )Nc                 \    g | ])}t          |t                    st          |d           n|*S )mbcs)
isinstancer   .0rO   s     r"   
<listcomp>zsend2trash.<locals>.<listcomp>   s7    dddVZJtY,G,GQYtV$$$Tdddr!   c                 b    g | ],}t          j        |          st          j        |          n|-S r    )opisabsabspathrd   s     r"   rf   zsend2trash.<locals>.<listcomp>   s4    PPP$RXd^^=RZPPPr!   c                 ,    g | ]}t          |          S r    )r_   rd   s     r"   rf   zsend2trash.<locals>.<listcomp>   s!    9994 &&999r!   r     r#   )r   r   r   	FO_DELETEr   r
   joinrU   r   r   r   r   FOF_ALLOWUNDOFOF_NOCONFIRMATIONFOF_NOERRORUI
FOF_SILENTr   r   r   r   SHFileOperationWr   rK   rY   r   )pathsfileopbufferpath_stringrI   errors         r"   
send2trashrz      sP   U##E dd^cdddEPP%PPPE995999EFFKFL" #388E??33F))E""K";Fa@@F9V,,--FLFJ!$66FSFM#$F F#FeFmm,,F C*6224U!3!3UEBBBC Cr!   )*
__future__r   os.pathrO   rh   send2trash.compatr   send2trash.utilr   ctypesr   r   r   r	   r
   r   r   r   ctypes.wintypesr   r   r   r   kernel32rX   shell32rt   r   FO_MOVEFO_COPYrn   	FO_RENAMEFOF_MULTIDESTFILESrs   rq   rp   rr   rK   rR   rV   r_   rz   r    r!   r"   <module>r      s   ( ' ' ' ' '       ' ' ' ' ' ' , , , , , ,	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 6 5 5 5 5 5 5 5 5 5 5 5?. 
.+ 
 
 
 
 
i 
 
 
 
		 
  '  '  'F  0	 	 	
> 
> 
>*C *C *C *C *Cr!   