]> git.proxmox.com Git - rustc.git/blobdiff - src/bootstrap/build/util.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / bootstrap / build / util.rs
index 6c700671f11115d396897e1e537a5ca66f6364f0..41cf924d44a92dcf85ddce41ff058e3c5040398c 100644 (file)
@@ -30,7 +30,15 @@ pub fn mtime(path: &Path) -> FileTime {
     }).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);
@@ -43,7 +51,7 @@ pub fn cp_r(src: &Path, dst: &Path) {
             cp_r(&path, &dst);
         } else {
             let _ = fs::remove_file(&dst);
-            t!(fs::hard_link(&path, dst));
+            copy(&path, &dst);
         }
     }
 }