6"""Emulation of `rm -f out && cp -af` in out. This is necessary on Mac in order
7to preserve nanoseconds of mtime. See https://fxbug.dev/56376#c5."""
15 if len(sys.argv) != 3:
16 print(
'usage: copy.py source dest', file=sys.stderr)
21 if os.path.isdir(source):
22 print(f
'{source} is a directory, tool "copy" does not support directory copies')
25 if os.path.exists(dest):
26 if os.path.isdir(dest):
28 def _on_error(fn, path, dummy_excinfo):
32 if not os.access(path, os.W_OK):
33 os.chmod(path, stat.S_IWRITE)
36 shutil.rmtree(dest, onerror=_on_error)
38 if not os.access(dest, os.W_OK):
40 os.chmod(dest, stat.S_IWRITE)
43 shutil.copy2(source, dest)
46if __name__ ==
'__main__':
def print(*args, **kwargs)