[][src]Function fungus::sys::copyfile_p

pub fn copyfile_p<T: AsRef<Path>, U: AsRef<Path>>(
    src: T,
    dst: U
) -> FuResult<Copyfile>

Copies a single file from src to dst, creating destination directories as needed and handling path expansion and optionally following links.

The dst will be copied to if it is an existing directory. The dst will be a clone of the src if it doesn't exist. Doesn't follow links

Examples

use fungus::prelude::*;

let tmpdir = PathBuf::from("tests/temp").abs().unwrap().mash("file_doc_copyfile_p");
assert!(sys::remove_all(&tmpdir).is_ok());
assert!(sys::mkdir(&tmpdir).is_ok());
let file1 = tmpdir.mash("file1");
let file2 = tmpdir.mash("file2");
assert!(sys::touch_p(&file1, 0o644).is_ok());
assert!(sys::copyfile_p(&file1, &file2).unwrap().mode(0o555).copy().is_ok());
assert_eq!(file2.mode().unwrap(), 0o100555);
assert!(sys::remove_all(&tmpdir).is_ok());