Release 2024.07.08
[yt-dlp.git] / yt_dlp / compat / shutil.py
blob23239d5ce84a7d73de6320968bb63a3626ea26eb
1 # flake8: noqa: F405
2 from shutil import * # noqa: F403
4 from .compat_utils import passthrough_module
6 passthrough_module(__name__, 'shutil')
7 del passthrough_module
10 import sys
12 if sys.platform.startswith('freebsd'):
13 import errno
14 import os
15 import shutil
17 # Workaround for PermissionError when using restricted ACL mode on FreeBSD
18 def copy2(src, dst, *args, **kwargs):
19 if os.path.isdir(dst):
20 dst = os.path.join(dst, os.path.basename(src))
21 shutil.copyfile(src, dst, *args, **kwargs)
22 try:
23 shutil.copystat(src, dst, *args, **kwargs)
24 except PermissionError as e:
25 if e.errno != getattr(errno, 'EPERM', None):
26 raise
27 return dst
29 def move(*args, copy_function=copy2, **kwargs):
30 return shutil.move(*args, copy_function=copy_function, **kwargs)