o
    "7h                     @   s>   d Z ddlZddlmZmZ ddlmZ dgZ	d	ddZdS )
z
Move a file in the safest way possible::

    >>> from django.core.files.move import file_move_safe
    >>> file_move_safe("/tmp/old_file", "/tmp/new_file")
    N)copymodecopystat)locksfile_move_safe   Fc                 C   s  zt j| |rW dS W n	 ty   Y nw |s't |t jr'td| dz	t | | W dS  ty9   Y nw t| dV}t |t j	t j
B tt ddB |sSt jndB t jB }z(t|tj d}|dkrw||}t || |dkshW t| t | nt| t | w W d   n1 sw   Y  zt| | W n ty   zt| | W n	 ty   Y nw Y nw zt |  W dS  ty } zt|ddd	kr؂ W Y d}~dS d}~ww )
aU  
    Move a file from one location to another in the safest way possible.

    First, try ``os.rename``, which is simple but will break across filesystems.
    If that fails, stream manually from one file to another in pure Python.

    If the destination file exists and ``allow_overwrite`` is ``False``, raise
    ``FileExistsError``.
    NzDestination file z% exists and allow_overwrite is False.rbO_BINARYr       winerror    )ospathsamefileOSErroraccessF_OKFileExistsErrorrenameopenO_WRONLYO_CREATgetattrO_EXCLO_TRUNCr   lockLOCK_EXreadwriteunlockcloser   PermissionErrorr   remove)old_file_namenew_file_name
chunk_sizeallow_overwriteold_filefdcurrent_chunke r*   k/var/www/epreuve.sigeris.cm/public_html/epreuve/venv/lib/python3.10/site-packages/django/core/files/move.pyr      sz   






)r   F)	__doc__r   shutilr   r   django.core.filesr   __all__r   r*   r*   r*   r+   <module>   s    