[][src]Function reflink::reflink_or_copy

pub fn reflink_or_copy<P: AsRef<Path>, Q: AsRef<Path>>(
    from: P,
    to: Q
) -> Result<Option<u64>>

Attempts to reflink a file. If the operation fails, a conventional copy operation is attempted as a fallback.

If the function reflinked a file, the return value will be `Ok(None)``.

If the function copied a file, the return value will be Ok(Some(written)).

use reflink;
match reflink::reflink_or_copy("src.txt", "dest.txt") {
    Ok(None) => println!("file has been reflinked"),
    Ok(Some(written)) => println!("file has been copied ({} bytes)", written),
    Err(e) => println!("an error occured: {:?}", e)
}