copy_file

Function copy_file 

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

§Atomic File Copy!

Copy the contents — and permissions, ownership, and access/modification times — of one file to another, atomically.

Similar to write_file, this method first copies everything over to a temporary file before moving it into place.

§Examples

// It's just one line:
match write_atomic::copy_file("/some/source.jpg", "/some/copy.jpg") {
    // The file was copied!
    Ok(()) => {},

    // There was an std::io::Error.
    Err(e) => panic!("{e}"),
};

§Errors

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