Ë
    Î£j†  ã                   ó’  — d dl Z d dlZd dlZd dlZd dlmZmZ d dlmZ  e j                  «       Z
dedefd„Zddededdfd„Z	 	 	 dd	ed
edededz  deeee   gef   dz  dedz  fd„Z	 	 	 dd	ed
edededz  deeee   gef   dz  dedz  fd„Zdedefd„Zdedeeef   fd„Zddedededdfd„Zddedededdfd„Zdedefd„Zy)é    N)ÚCallableÚSequence)ÚPathÚfileÚreturnc                 ó  — 	 	 | j                  t        j                  t        j                  z  t        j                  z  «      5  | cddd«       S # 1 sw Y   nxY wn-# t
        $ r! | j                  | j                  dz   «      } Y nw xY wŒ‰)zõ
    Atomically create a new file, appending underscores to its name until valid, and return a path-like object representing it.

    Args:
        file: The base file name.
    Returns:
        A path-like object representing the new file.
    NÚ_)ÚopenÚosÚO_CREATÚO_EXCLÚO_WRONLYÚFileExistsErrorÚ	with_nameÚname©r   s    úAC:\Users\pivot\Documents\cueki\casual-preloader\core\util\file.pyÚ_get_next_new_filer      sk   € ð ð	3Ø—‘œ2Ÿ:™:¬¯	©	Ñ1´B·K±KÑ?Õ@Ø÷ A×@Ò@úÐ@øäò 	3Ø—>‘> $§)¡)¨c¡/Ó2ŠDð	3úð	 s*   ƒAA ÁAÁ	A ÁAÁA Á'BÂBÚnot_exist_okc                 óp  — 	 | j                  «       s*|rt        j                  d| › d�«       yt        d| › �«      ‚| j	                  «       }|r| j                  «        nt        j                  | «       t        j                  d|xr dxs d› d| › �«       y# t        $ r}t        d	| › �«      |‚d}~ww xY w)
zš
    Delete a file or directory.

    Args:
        file: The file to delete.
        not_exist_ok: Do not throw an error if the file does not exist.
    zCannot delete ú because it does not existNú%[Errno 2] No such file or directory: zDeleted r   ÚfolderÚ zError deleting )	ÚexistsÚlogÚdebugÚFileNotFoundErrorÚis_fileÚunlinkÚshutilÚrmtreeÚ	Exception)r   r   r   Úes       r   Údeleter%   !   s«   € ð9Ø�{‰{Œ}ÙÜ—	‘	˜N¨4¨&Ð0JÐKÔLØä'Ð*OÐPTÈvÐ(VÓWÐWà—,‘,“.ˆáØ�K‰K�Mä�M‰M˜$Ôä�	‰	�H˜WÒ/¨Ò;°8Ð<¸A¸d¸VÐDÕEøÜò 9Ü˜/¨$¨Ð0Ó1°qÐ8ûð9ús   ‚+B ®A)B Â	B5Â!B0Â0B5ÚsrcÚdstÚ	noclobberÚignorec                 óT  — | |k(  rt         j                  d| › d�«       y	 | j                  «       s-|rt         j                  d| › d|› d�«       yt        d| › �«      ‚|€t	        |«      }n |r|j                  «       rt        d|› �«      ‚|j                  j                  d	d	¬
«       | j                  «       rt        j                  | |«       nt        j                  | ||| ¬«       t         j                  d| › d|› �«       |S # t        $ r}t        d| › d|› �«      |‚d}~ww xY w)aî  
    Copy a file or directory.

    Args:
        src: The source file.
        dst: The destination file.
        not_exist_ok: Do not throw an error if the source does not exist.
        noclobber: Throw an error if the destination exists (i.e. do not overwrite files). A value of `None` tries to append a suffix to the filename.
        ignore: A callable that is passed to the `ignore` argument of `shutil.copytree()`.

    Returns:
        The destination path upon a successful copy.
    zTried copying ú to itself, skipping...NzCannot copy ú -> ú as source does not existr   ú[Errno 17] File exists: T©ÚparentsÚexist_ok)Údirs_exist_okzCopied zError copying )r   r   r   r   r   r   ÚparentÚmkdirr   r!   Úcopy2Úcopytreer#   ©r&   r'   r   r(   r)   r$   s         r   Úcopyr8   >   s#  € ð* ˆc‚zÜ�	‰	�N 3 %Ð'>Ð?Ô@Øð@Ø�z‰zŒ|ÙÜ—	‘	˜L¨¨¨T°#°Ð6OÐPÔQØä'Ð*OÐPSÈuÐ(UÓVÐVàÐÜ$ SÓ)‰CÙ˜3Ÿ:™:œ<Ü!Ð$<¸S¸EÐ"BÓCÐCà�
‰
×Ñ °ÐÔ5Ø�;‰;Œ=Ü�L‰L˜˜cÕ"ä�O‰O˜C  fÀ¸]ÕLä�	‰	�G˜C˜5  S EÐ*Ô+Øˆ
øÜò @Ü˜.¨¨¨T°#°Ð7Ó8¸aÐ?ûð@ús   ¡.D ÁB6D Ä	D'ÄD"Ä"D'c                 ó8  — | |k(  rt         j                  d| › d�«       y	 | j                  «       s-|rt         j                  d| › d|› d�«       yt        d| › �«      ‚|€t	        |«      }n |r|j                  «       rt        d|› �«      ‚|j                  j                  d	d	¬
«       |rt        | |d||«       t        | «       nt        j                  | |«       t         j                  d| › d|› �«       |S # t        $ r}t        d| › d|› �«      |‚d}~ww xY w)aî  
    Move a file or directory.

    Args:
        src: The source file.
        dst: The destination file.
        not_exist_ok: Do not throw an error if the source does not exist.
        noclobber: Throw an error if the destination exists (i.e. do not overwrite files). A value of `None` tries to append a suffix to the filename.
        ignore: A callable that is passed to the `ignore` argument of `shutil.copytree()`.

    Returns:
        The destination path upon a successful move.
    zTried moving r+   NzCannot move r,   r-   r   r.   Tr/   FzMoved zError moving
)r   r   r   r   r   r   r3   r4   r8   r%   r!   Úmover#   r7   s         r   r:   r:   p   s   € ð* ˆc‚zÜ�	‰	�M # Ð&=Ð>Ô?Øð@Ø�z‰zŒ|ÙÜ—	‘	˜L¨¨¨T°#°Ð6OÐPÔQØä'Ð*OÐPSÈuÐ(UÓVÐVàÐÜ$ SÓ)‰CÙ˜3Ÿ:™:œ<Ü!Ð$<¸S¸EÐ"BÓCÐCà�
‰
×Ñ °ÐÔ5ÙÜ��c˜5 )¨VÔ4Ü�3�Kä�K‰K˜˜SÔ!ä�	‰	�F˜3˜%˜t C 5Ð)Ô*Øˆ
øÜò @Ü˜.¨¨¨T°#°Ð7Ó8¸aÐ?ûð@ús   ¡.C9 ÁB(C9 Ã9	DÄDÄDÚmodec                 óæ  — d}|| t         j                  z  rdndz  }|| t         j                  z  rdndz  }|| t         j                  z  rdndz  }|| t         j                  z  rdndz  }|| t         j
                  z  rdndz  }|| t         j                  z  rdndz  }|| t         j                  z  rdndz  }|| t         j                  z  rdndz  }|| t         j                  z  rdz  }|S dz  }|S )zÓ
    Format a file permission mode into a human-readable representation (e.g. rwxrwxrwx).

    Args:
        mode: The mode bits to format.

    Returns:
        A human-readble representation of mode bits.
    Ú ÚrÚ-ÚwÚx)
ÚstatÚS_IRUSRÚS_IWUSRÚS_IXUSRÚS_IRGRPÚS_IWGRPÚS_IXGRPÚS_IROTHÚS_IWOTHÚS_IXOTH)r;   Úrets     r   Ú_format_moderM   £   sê   € ð €Cà�$œŸ™Ò%‰3¨3Ñ.€CØ�$œŸ™Ò%‰3¨3Ñ.€CØ�$œŸ™Ò%‰3¨3Ñ.€Cà�$œŸ™Ò%‰3¨3Ñ.€CØ�$œŸ™Ò%‰3¨3Ñ.€CØ�$œŸ™Ò%‰3¨3Ñ.€Cà�$œŸ™Ò%‰3¨3Ñ.€CØ�$œŸ™Ò%‰3¨3Ñ.€CØ�$œŸ™Ò%ˆ3Ñ.€Cà€Jð ,/Ñ.€Cà€Jó    c                 óŠ   — | j                  «       j                  }t        |«      }t        j	                  d|› d| › �«       ||fS )z±
    Retrieve a file's mode bits.

    Args:
        file: The file to operate on.
    Returns:
        A tuple of the file's mode bits and a human-readable representation.
    z	got mode ú for )rB   Úst_moderM   r   r   )r   r;   Úf_modes      r   Ú_modegetrS   ¿   sB   € ð �9‰9‹;×Ñ€DÜ˜$Ó€FÜ‡I�I�	˜&˜  t fÐ-Ô.Ø�ˆ<ÐrN   c                 ó  — 	 |r*| j                  «       st        j                  d| › d�«       y| j                  |«       t        j                  dt	        |«      › d| › �«       y# t
        $ r}t        d| › �«      |‚d}~ww xY w)zµ
    Change a file's mode bits.

    Args:
        file: The file to operate on.
        mode: The mode.
        not_exist_ok: Do not throw an error if the file does not exist.
    úCannot get/set mode for r   Nú	set mode rP   úunable to get/set mode for )r   r   r   ÚchmodrM   r#   )r   r;   r   r$   s       r   ÚmodesetrY   Ï   s   € ðEÙ §¡¤Ü�I‰IÐ0°°Ð6PÐQÔRØà�
‰
�4ÔÜ�	‰	�Iœl¨4Ó0Ð1°°t°fÐ=Õ>øÜò EÜÐ5°d°VÐ<Ó=À1ÐDûðEús   ‚+A$ ®5A$ Á$	BÁ-A<Á<Bc                 ó.  — 	 |r*| j                  «       st        j                  d| › d�«       yt        | «      \  }}||z  }| j	                  |«       t        j                  dt        |«      › d| › �«       y# t        $ r}t        d| › �«      |‚d}~ww xY w)zà
    Additively change a file's mode bits.

    Args:
        file: The file to operate on.
        mode: The mode bitwise OR with the file's mode.
        not_exist_ok: Do not throw an error if the file does not exist.
    rU   r   NrV   rP   rW   )r   r   r   rS   rX   rM   r#   )r   r;   r   Ú_moder	   r$   s         r   Úmodeset_addr\   ä   s•   € ðEÙ §¡¤Ü�I‰IÐ0°°Ð6PÐQÔRØä˜D“>‰ˆˆqà�‰ˆØ�
‰
�4ÔÜ�	‰	�Iœl¨4Ó0Ð1°°t°fÐ=Õ>øÜò EÜÐ5°d°VÐ<Ó=À1ÐDûðEús   ‚+A7 ®AA7 Á7	BÂ BÂBc                 óh   — 	 t        | d«      5  	 ddd«       y# 1 sw Y   yxY w# t        $ r Y yw xY w)zÃ
    Check if a file can be written to (not locked by another process).

    Args:
        file: The file to check.

    Returns:
        True if the file can be written to, False otherwise.
    zr+bNTF)r
   ÚPermissionErrorr   s    r   Úcheck_writabler_   ü   s6   € ðÜ�$˜ÕØ÷ à÷ àûÜò Ùðús    ‚% Ž�% ™"ž% ¢% ¥	1°1)F)FFN)Úloggingr   r!   rB   Úcollections.abcr   r   Úpathlibr   Ú	getLoggerr   r   Úboolr%   ÚstrÚlistr8   r:   ÚintrM   ÚtuplerS   rY   r\   r_   © rN   r   Ú<module>rj      sÂ  ðÛ Û 	Û Û ß .Ý à€g×ÑÓ€ð3˜Tð 3 dó 3ñ$9�ð 9 Tð 9°dó 9ð@ Ø"Ø:>ñ/@Ø	ð/@à	ð/@ð ð/@ð �d‰{ð	/@ð
 �c˜4 ™9Ð% xÐ/Ñ0°4Ñ7ð/@ð 
ˆD�[ó/@ðj Ø"Ø:>ñ0@Ø	ð0@à	ð0@ð ð0@ð �d‰{ð	0@ð
 �c˜4 ™9Ð% xÐ/Ñ0°4Ñ7ð0@ð 
ˆD�[ó0@ðf�sð ˜só ð8�4ð ˜E # s (™Oó ñ E�$ð E˜cð E°ð EÀ$ó Eñ*E�dð E #ð E°Tð EÀdó Eð0˜ð  $ô rN   