]> jfr.im git - yt-dlp.git/blob - yt_dlp/compat/shutil.py
[ie/brightcove] Upgrade requests to HTTPS (#10202)
[yt-dlp.git] / yt_dlp / compat / shutil.py
1 # flake8: noqa: F405
2 from shutil import * # noqa: F403
3
4 from .compat_utils import passthrough_module
5
6 passthrough_module(__name__, 'shutil')
7 del passthrough_module
8
9
10 import sys
11
12 if sys.platform.startswith('freebsd'):
13 import errno
14 import os
15 import shutil
16
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
28
29 def move(*args, copy_function=copy2, **kwargs):
30 return shutil.move(*args, copy_function=copy_function, **kwargs)