mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-02 14:07:46 +00:00
Fix link.
This commit is contained in:
parent
7c732bcefe
commit
6911c7e2ce
1 changed files with 9 additions and 8 deletions
|
@ -1,5 +1,5 @@
|
|||
#![crate_name = "link"]
|
||||
#![feature(collections, core, old_io, old_path, rustc_private)]
|
||||
#![feature(rustc_private)]
|
||||
|
||||
/*
|
||||
* This file is part of the uutils coreutils package.
|
||||
|
@ -12,8 +12,9 @@
|
|||
|
||||
extern crate getopts;
|
||||
|
||||
use std::old_io::fs::link;
|
||||
use std::old_path::Path;
|
||||
use std::io::Write;
|
||||
use std::fs::hard_link;
|
||||
use std::path::Path;
|
||||
|
||||
#[path="../common/util.rs"]
|
||||
#[macro_use]
|
||||
|
@ -28,7 +29,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
|||
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,
|
||||
Err(err) => panic!("{}", err),
|
||||
};
|
||||
|
@ -44,17 +45,17 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
|||
println!("Usage:");
|
||||
println!(" {} [OPTIONS] FILE1 FILE2", NAME);
|
||||
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 {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
let old = Path::new(matches.free[0].as_slice());
|
||||
let new = Path::new(matches.free[1].as_slice());
|
||||
let old = Path::new(&matches.free[0]);
|
||||
let new = Path::new(&matches.free[1]);
|
||||
|
||||
match link(&old, &new) {
|
||||
match hard_link(old, new) {
|
||||
Ok(_) => 0,
|
||||
Err(err) => {
|
||||
show_error!("{}", err);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue