[−][src]Function reflink::reflink
pub fn reflink<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> Result<()>
Copies a file using COW semantics.
For compatibility reasons with macos, the target file will be created using OpenOptions::create_new
.
If you want to overwrite existing files, make sure you manually delete the target file first
if it exists.
use reflink; match reflink::reflink("src.txt", "dest.txt") { Ok(()) => println!("file has been reflinked"), Err(e) => println!("error while reflinking: {:?}", e) }
Implementation details per platform
Linux / Android
Uses ioctl_ficlone
. Supported file systems include btrfs and XFS (and maybe more in the future).
OS X / ios
Uses clonefile
library function. This is supported on OS X Version >=10.12 and iOS version >= 10.0
This will work on APFS partitions (which means most desktop systems are capable).
Windows
Uses ioctl FSCTL_DUPLICATE_EXTENTS_TO_FILE
.
Only supports ReFS on Windows Server. Important note: The windows implementation is currently
untested and probably buggy. Contributions/testers with access to a Windows Server welcome.