File: //usr/lib/python3/dist-packages/django/utils/__pycache__/_os.cpython-310.pyc
o
�a� � @ s` d dl Z d dlZd dlmZmZmZmZmZ d dlm Z d dl
mZ dd� Zdd� Z
d d
� ZdS )� N)�abspath�dirname�join�normcase�sep)�Path)�SuspiciousFileOperationc G sj t t| g|�R � �}t | �}t|��t|t ��s3t|�t|�kr3tt|��t|�kr3td�||���|S )z�
Join one or more path components to the base path component intelligently.
Return a normalized, absolute version of the final path.
Raise ValueError if the final path isn't located inside of the base path
component.
zGThe joined path ({}) is located outside of the base path component ({}))r r r �
startswithr r r �format)�base�paths�
final_path� base_path� r �2/usr/lib/python3/dist-packages/django/utils/_os.py� safe_join s �r c
C s� t �� �5} tj�| d�}tj�| d�}t�|� z
t�||� d}W n
ttfy/ d}Y nw |W d � S 1 s<w Y dS )z�
Return whether or not creating symlinks are supported in the host platform
and/or if they are allowed to be created (e.g. on Windows it requires admin
permissions).
�original�symlinkTFN) �tempfile�TemporaryDirectory�os�pathr �makedirsr �OSError�NotImplementedError)�temp_dir�
original_path�symlink_path� supportedr r r �symlinks_supported# s
�$�r c C s2 t | t�r| S t | t�stdt| �j ��t| �S )z@Convert value to a pathlib.Path instance, if not already a Path.zInvalid path type: %s)�
isinstancer �str� TypeError�type�__name__)�valuer r r �to_path5 s
r&