Skip to content

Commit fabd49b

Browse files
committed
Use os::copy_file in cargo
1 parent 8dd2213 commit fabd49b

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/cargo/cargo.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -478,14 +478,13 @@ fn install_one_crate(c: cargo, path: str, cf: str) {
478478
(exec_suffix == "" && !str::starts_with(path::basename(ct),
479479
"lib")) {
480480
#debug(" bin: %s", ct);
481-
// FIXME: need libstd os::copy or something (Issue #1983)
482-
run::run_program("cp", [ct, c.bindir]);
481+
copy_warn(ct, c.bindir);
483482
if c.opts.mode == system_mode {
484483
install_one_crate_to_sysroot(ct, "bin");
485484
}
486485
} else {
487486
#debug(" lib: %s", ct);
488-
run::run_program("cp", [ct, c.libdir]);
487+
copy_warn(ct, c.bindir);
489488
if c.opts.mode == system_mode {
490489
install_one_crate_to_sysroot(ct, libdir());
491490
}
@@ -499,10 +498,7 @@ fn install_one_crate_to_sysroot(ct: str, target: str) {
499498
let path = [_path, "..", target];
500499
check vec::is_not_empty(path);
501500
let target_dir = path::normalize(path::connect_many(path));
502-
let p = run::program_output("cp", [ct, target_dir]);
503-
if p.status != 0 {
504-
warn(#fmt["Copying %s to %s is failed", ct, target_dir]);
505-
}
501+
copy_warn(ct, target_dir);
506502
}
507503
none { }
508504
}
@@ -772,7 +768,7 @@ fn sync_one(c: cargo, name: str, src: source) {
772768
info(#fmt["no signature for source %s", name]);
773769
}
774770
}
775-
run::run_program("cp", [pkgfile, destpkgfile]);
771+
copy_warn(pkgfile, destpkgfile);
776772
}
777773

778774
fn cmd_sync(c: cargo) {
@@ -812,7 +808,7 @@ fn cmd_init(c: cargo) {
812808
} else {
813809
info(#fmt["signature ok for sources.json"]);
814810
}
815-
run::run_program("cp", [srcfile, destsrcfile]);
811+
copy_warn(srcfile, destsrcfile);
816812

817813
info(#fmt["Initialized .cargo in %s", c.root]);
818814
}
@@ -853,6 +849,12 @@ fn cmd_search(c: cargo) {
853849
info(#fmt["Found %d packages.", n]);
854850
}
855851

852+
fn copy_warn(src: str, dest: str) {
853+
if !os::copy_file(src, dest) {
854+
warn(#fmt["Copying %s to %s failed", src, dest]);
855+
}
856+
}
857+
856858
fn cmd_usage() {
857859
print("Usage: cargo <verb> [options] [args...]" +
858860
"

0 commit comments

Comments
 (0)