Using bash on macos I can create COW file clones with cp -c
. Is there a Python library that provides the same functionality? The copy functions in shutil doesn't seem to mention cloning.
On APFS clones: https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/APFS_Guide/Features/Features.html
On BSD clonefile: http://www.manpagez.com/man/2/clonefile/
The Python standard library does not support cloning files.
To clone a file using cp -c
in a subprocess you can use this function:
def clonefile(source, dest):
subprocess.check_output(["cp", "-c", source, dest])