
    dh                         S SK r S SKJr  S SKJr  S SKJr  S\S\S\4S jrS	r	 " S
 S\
5      r " S S\5      rS\S\S\4S jrg)    N)Path)Optional)	BaseModelpathrootreturnc                     [         R                  S:  a  U R                  U5      $  U R                  U5        g! [         a     gf = f)z"Check if path is relative to root.)   	   TF)sysversion_infois_relative_torelative_to
ValueError)r   r   s     g/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/tools/file_management/utils.pyr   r      sI    
6!""4(( s   9 
AAzlError: Access denied to {arg_name}: {value}. Permission granted exclusively to the current working directoryc                       \ rS rSrSrSrg)FileValidationError   z+Error for paths outside the root directory. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r       r   r   r      s    5r   r   c                   B    \ rS rSr% SrSr\\   \S'    S\S\	4S jr
Srg)	BaseFileToolMixin   zMixin for file system tools.Nroot_dir	file_pathr   c                 p    U R                   c  [        U5      $ [        [        U R                   5      U5      $ )z9Get the relative path, returning an error if unsupported.)r    r   get_validated_relative_path)selfr!   s     r   get_relative_path#BaseFileToolMixin.get_relative_path$   s,    == 	?"*4+>	JJr   r   )r   r   r   r   r   r    r   str__annotations__r   r%   r   r   r   r   r   r      s,    &"Hhsm"JK3 K4 Kr   r   	user_pathc                     U R                  5       n X-  R                  5       n[        X 5      (       d  [        SU SU  35      eU$ )zKResolve a relative path, raising an error if not within the root directory.zPath z% is outside of the allowed directory )resolver   r   )r   r)   	full_paths      r   r#   r#   +   sQ     <<>D!**,I)**!I;CD6J
 	
 r   )r   pathlibr   typingr   pydanticr   boolr   INVALID_PATH_TEMPLATEr   r   r   r'   r#   r   r   r   <module>r2      sj    
   	 	T 	d 	G 6* 6
K	 
Kd s t r   