}).unwrap_or(FileTime::zero())
}
-#[allow(dead_code)] // this will be used soon
+pub fn copy(src: &Path, dst: &Path) {
+ let res = fs::hard_link(src, dst);
+ let res = res.or_else(|_| fs::copy(src, dst).map(|_| ()));
+ if let Err(e) = res {
+ panic!("failed to copy `{}` to `{}`: {}", src.display(),
+ dst.display(), e)
+ }
+}
+
pub fn cp_r(src: &Path, dst: &Path) {
for f in t!(fs::read_dir(src)) {
let f = t!(f);
cp_r(&path, &dst);
} else {
let _ = fs::remove_file(&dst);
- t!(fs::hard_link(&path, dst));
+ copy(&path, &dst);
}
}
}