[][src]Function librelic::prelude::sys::copy

pub fn copy<T, U>(src: T, dst: U) -> Result<PathBuf, FuError> where
    T: AsRef<Path>,
    U: AsRef<Path>, 

Copies src to dst recursively creating destination directories as needed and handling path expansion and globbing e.g. copy("./*", "../") and returning an absolute path of the destination.

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_copy");
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(&file1).is_ok());
assert!(sys::copy(&file1, &file2).is_ok());
assert_eq!(file2.exists(), true);
assert!(sys::remove_all(&tmpdir).is_ok());