Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions sebaubuntu_libs/libcompat/distutils/file_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,19 @@ def copy_file( # noqa: C901
# (not update) and (src newer than dst).

from ._modified import newer
from stat import S_IMODE, ST_ATIME, ST_MODE, ST_MTIME
from stat import S_IMODE, S_ISCHR, ST_ATIME, ST_MODE, ST_MTIME

st = os.stat(src)

if not os.path.isfile(src):
raise DistutilsFileError(
"can't copy '%s': doesn't exist or not a regular file" % src
)
if S_ISCHR(st[ST_MODE]):
if verbose >= 1:
LOGD("not copying %s (file is character device)", src)
return (dst, 0)
else:
raise DistutilsFileError(
"can't copy '%s': doesn't exist or not a regular file" % src
)

if os.path.isdir(dst):
dir = dst
Expand Down Expand Up @@ -156,8 +163,6 @@ def copy_file( # noqa: C901
# (optionally) copy the times and mode.
_copy_file_contents(src, dst)
if preserve_mode or preserve_times:
st = os.stat(src)

# According to David Ascher <da@ski.org>, utime() should be done
# before chmod() (at least under NT).
if preserve_times:
Expand Down