o
    ¹i?  ã                   @   sà   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	„ d	eƒZdZd
ZdZdZdZ dZ!dZ"dZ#dZ$dd„ Z%dd„ Z&dd„ Z'd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                	   @   s@   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_© r   r   úU/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/send2trash/plat_win_legacy.pyr      s    ør   é   é   é   é   é@   i   c                 C   sd   d| }}|   |¡s%|   d¡rd}|| dd…  }||fS ||  }||fS |   |d ¡r.d}||fS )zÞGuess 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_pathr   r   r    Úprefix_and_path8   s   


ûür+   c                 C   s,   | dkrd|t | ƒd…  S |t | ƒd… S )z©Guess 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.
    r&   ú\N)Úlen)r)   r(   r   r   r    Úget_awaited_path_from_prefixP   s   r.   c                 C   sR   t | ƒ\}}t|d dƒ}|stƒ }t|t|ƒ|ƒ‚t|ƒ}t|||ƒ t||jƒS )Nr   )r+   ÚGetShortPathNameWr   ÚWindowsErrorr   r
   r.   Úvalue)Ú	long_namer)   r*   Úbuf_sizeÚerr_noÚoutputr   r   r    Úget_short_path_name\   s   r6   c                 C   sÊ   t | ƒ} dd„ | D ƒ} dd„ | D ƒ} dd„ | D ƒ} tƒ }d|_t|_td | ¡ƒ}d | ¡}t|t|ƒd ƒ}tt	|ƒƒ|_
d |_ttB tB tB |_d|_d|_d |_tt|ƒƒ}|rct|t|ƒ| ƒ‚d S )	Nc                 S   s$   g | ]}t |tƒst|d ƒn|‘qS )Úmbcs)Ú
isinstancer   ©Ú.0r(   r   r   r    Ú
<listcomp>l   s    ÿÿzsend2trash.<locals>.<listcomp>c                 S   s$   g | ]}t  |¡st  |¡n|‘qS r   )ÚopÚisabsÚabspathr9   r   r   r    r;   q   s   $ c                 S   s   g | ]}t |ƒ‘qS r   )r6   r9   r   r   r    r;   s   s    r   ú ú r   )r   r   r   Ú	FO_DELETEr   r
   Újoinr-   r   r   r   r   ÚFOF_ALLOWUNDOÚFOF_NOCONFIRMATIONÚFOF_NOERRORUIÚ
FOF_SILENTr   r   r   r   ÚSHFileOperationWr   r0   r   )ÚpathsÚfileopÚbufferÚpath_stringÚresultr   r   r    Ú
send2trashi   s,   þ
ÿrM   ))Ú
__future__r   Úos.pathr(   r<   Úcompatr   Úutilr   Úctypesr   r   r   r	   r
   r   r   r   Úctypes.wintypesr   r   r   r   Úkernel32r/   Úshell32rG   r   ÚFO_MOVEÚFO_COPYrA   Ú	FO_RENAMEÚFOF_MULTIDESTFILESrF   rD   rC   rE   r+   r.   r6   rM   r   r   r   r    Ú<module>   s0   (
