Skip to main content

clonefile_or_copy

Function clonefile_or_copy 

Source
pub fn clonefile_or_copy(source: &Path, dest: &Path) -> Result<bool>
Expand description

Reflink if possible, otherwise fall back to a real copy. Returns the same Ok(true)/Ok(false) discriminator as try_reflinktrue when the OS gave us a CoW clone, false when we paid the full copy cost. Either way, on Ok the destination exists and has the source’s bytes.

The destination’s permission bits are not normalized here. Callers that need a specific mode (0o644, 0o755) should call fs::set_permissions after a successful return.