mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-03 22:47:46 +00:00
link: normalize file-not-found error message across platforms
This commit is contained in:
parent
396c1642a2
commit
3e6ac628bc
1 changed files with 9 additions and 1 deletions
|
@ -17,10 +17,18 @@ extern crate uucore;
|
|||
use std::fs::hard_link;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
use std::io::Error;
|
||||
|
||||
static NAME: &'static str = "link";
|
||||
static VERSION: &'static str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
pub fn normalize_error_message(e: Error) -> String {
|
||||
match e.raw_os_error() {
|
||||
Some(2) => { String::from("No such file or directory (os error 2)") }
|
||||
_ => { format!("{}", e) }
|
||||
}
|
||||
}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> i32 {
|
||||
let mut opts = getopts::Options::new();
|
||||
|
||||
|
@ -58,7 +66,7 @@ Create a link named FILE2 to FILE1.", NAME, VERSION);
|
|||
match hard_link(old, new) {
|
||||
Ok(_) => 0,
|
||||
Err(err) => {
|
||||
show_error!("{}", err);
|
||||
show_error!("{}",normalize_error_message(err));
|
||||
1
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue