Function copy_file

Source
pub fn copy_file<P>(src: P, dst: P) -> Result<()>
where P: AsRef<Path>,
Expand description

§Atomic File Copy!

This will copy the contents of one file to another, atomically.

Under the hood, this uses std::fs::copy to copy the file to a temporary location. It then syncs the file permissions — and on Unix, the owner/group — before moving it to the final destination.

See write_file for more details about atomicity.

§Errors

This will bubble up any filesystem-related errors encountered along the way.