o
    Žõ±jA  ã                   @   s&   d dl mZ d dlT G dd„ dƒZdS )é    )ÚSMBFile)Ú*c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚSMBBlockingFileMgra!  
	This class implements a file object manager which can open/read/write files over the smbconnection
	The input/output queues used for communicating are process/thread/async safe!
	Therefore this creates a bridge between a non-async thread/process and the smb connection (file ops only!)
	c                 C   s"   || _ || _|| _i | _d| _d S )Nr   )Ú
connectionÚin_qÚout_qÚ
filehandleÚ	curhandle)Úselfr   r   r   © r   úŸ/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/aiosmb/commons/interfaces/blocking/file/file.pyÚ__init__   s
   
zSMBBlockingFileMgr.__init__c              
   Ã   sà  �	 d }�zÅ| j  ¡ I d H }|d u rW d S |jtjkrz?t | j|j¡}| 	| j|j
¡I d H \}}|d ur7|‚|| j| j< |  jd7  _t|j| jd |jƒ}| j |¡I d H  W �nn ty~ } zt|jt|ƒƒ}| j |¡I d H  W Y d }~�nOd }~ww |jtjkrçz>| j |j¡}| |jd¡I d H \}}|d urŸ|‚| |j¡I d H \}}|d ur°|‚t|j|j|ƒ}| j |¡I d H  W �n tyæ } zt|jt|ƒƒ}| j |¡I d H  W Y d }~nçd }~ww |jtjk�r8z%| j |j¡}| ¡ I d H  | j|j= t|j|jƒ}| j |¡I d H  W nµ t�y7 } zt|jt|ƒƒ}| j |¡I d H  W Y d }~n–d }~ww |jtj k�r¨zD| j |j¡}| |jd¡I d H \}}|d u�rZ|‚| !|j"¡I d H \}	}|d u�rl|‚| j|j= t#|j|j|	ƒ}| j |¡I d H  W nE t�y§ } zt|jt|ƒƒ}| j |¡I d H  W Y d }~n&d }~ww |jtj$k�rÉ| jD ]}
| j|
 }| ¡ I d H  | j|
= �q²W d S W n$ t�yî } zt|t|ƒƒ}| j |¡I d H  W Y d }~d S d }~ww q)NTé   r   )%r   Úcoro_getÚcmd_typeÚ
SMBFILECMDÚOPENr   Úfrom_remotepathr   ÚpathÚopenÚmoder   r	   ÚSMBFileOpenReplyÚcmd_idÚsizer   Úcoro_putÚ	ExceptionÚSMBFileErrorÚstrÚREADÚgetÚhandleÚseekÚpositionÚreadÚcountÚSMBFileReadReplyÚCLOSEÚcloseÚSMBFileCloseReplyÚWRITEÚwriteÚdataÚSMBFileWriteReplyÚ	TERMINATE)r
   ÚecmdidÚcmdÚsfÚ_ÚerrÚresÚer+   r$   r    r   r   r   Úrun   s¢   € €þ€þ
€þ


€þ

€€ý¼zSMBBlockingFileMgr.runN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r5   r   r   r   r   r      s    r   N)Úaiosmb.commons.interfaces.filer   Ú0aiosmb.commons.interfaces.blocking.file.protocolr   r   r   r   r   Ú<module>   s   