1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-02 14:07:46 +00:00

Fix link.

This commit is contained in:
Joseph Crail 2015-05-06 13:38:45 -04:00
parent 7c732bcefe
commit 6911c7e2ce

View file

@ -1,5 +1,5 @@
#![crate_name = "link"] #![crate_name = "link"]
#![feature(collections, core, old_io, old_path, rustc_private)] #![feature(rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -12,8 +12,9 @@
extern crate getopts; extern crate getopts;
use std::old_io::fs::link; use std::io::Write;
use std::old_path::Path; use std::fs::hard_link;
use std::path::Path;
#[path="../common/util.rs"] #[path="../common/util.rs"]
#[macro_use] #[macro_use]
@ -28,7 +29,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
getopts::optflag("V", "version", "output version information and exit"), getopts::optflag("V", "version", "output version information and exit"),
]; ];
let matches = match getopts::getopts(args.tail(), &opts) { let matches = match getopts::getopts(&args[1..], &opts) {
Ok(m) => m, Ok(m) => m,
Err(err) => panic!("{}", err), Err(err) => panic!("{}", err),
}; };
@ -44,17 +45,17 @@ pub fn uumain(args: Vec<String>) -> i32 {
println!("Usage:"); println!("Usage:");
println!(" {} [OPTIONS] FILE1 FILE2", NAME); println!(" {} [OPTIONS] FILE1 FILE2", NAME);
println!(""); println!("");
print!("{}", getopts::usage("Create a link named FILE2 to FILE1.", opts.as_slice()).as_slice()); print!("{}", getopts::usage("Create a link named FILE2 to FILE1.", &opts));
if matches.free.len() != 2 { if matches.free.len() != 2 {
return 1; return 1;
} }
return 0; return 0;
} }
let old = Path::new(matches.free[0].as_slice()); let old = Path::new(&matches.free[0]);
let new = Path::new(matches.free[1].as_slice()); let new = Path::new(&matches.free[1]);
match link(&old, &new) { match hard_link(old, new) {
Ok(_) => 0, Ok(_) => 0,
Err(err) => { Err(err) => {
show_error!("{}", err); show_error!("{}", err);