mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
ln: when we get a failed to link, show which files
This commit is contained in:
parent
bed7dc5a29
commit
15ef76fcbf
1 changed files with 4 additions and 4 deletions
|
@ -53,7 +53,7 @@ pub enum OverwriteMode {
|
||||||
enum LnError {
|
enum LnError {
|
||||||
TargetIsDirectory(PathBuf),
|
TargetIsDirectory(PathBuf),
|
||||||
SomeLinksFailed,
|
SomeLinksFailed,
|
||||||
FailedToLink(String),
|
FailedToLink(PathBuf, PathBuf, String),
|
||||||
SameFile(PathBuf, PathBuf),
|
SameFile(PathBuf, PathBuf),
|
||||||
MissingDestination(PathBuf),
|
MissingDestination(PathBuf),
|
||||||
ExtraOperand(OsString),
|
ExtraOperand(OsString),
|
||||||
|
@ -63,7 +63,7 @@ impl Display for LnError {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Self::TargetIsDirectory(s) => write!(f, "target {} is not a directory", s.quote()),
|
Self::TargetIsDirectory(s) => write!(f, "target {} is not a directory", s.quote()),
|
||||||
Self::FailedToLink(e) => write!(f, "failed to link: {}", e),
|
Self::FailedToLink(s, d, e) => write!(f, "failed to link {} to {}: {}", s.quote(), d.quote(), e),
|
||||||
Self::SameFile(e, e2) => write!(
|
Self::SameFile(e, e2) => write!(
|
||||||
f,
|
f,
|
||||||
"'{}' and '{}' are the same file",
|
"'{}' and '{}' are the same file",
|
||||||
|
@ -91,7 +91,7 @@ impl UError for LnError {
|
||||||
match self {
|
match self {
|
||||||
Self::TargetIsDirectory(_)
|
Self::TargetIsDirectory(_)
|
||||||
| Self::SomeLinksFailed
|
| Self::SomeLinksFailed
|
||||||
| Self::FailedToLink(_)
|
| Self::FailedToLink(_, _, _)
|
||||||
| Self::SameFile(_, _)
|
| Self::SameFile(_, _)
|
||||||
| Self::MissingDestination(_)
|
| Self::MissingDestination(_)
|
||||||
| Self::ExtraOperand(_) => 1,
|
| Self::ExtraOperand(_) => 1,
|
||||||
|
@ -293,7 +293,7 @@ fn exec(files: &[PathBuf], settings: &Settings) -> UResult<()> {
|
||||||
|
|
||||||
match link(&files[0], &files[1], settings) {
|
match link(&files[0], &files[1], settings) {
|
||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
Err(e) => Err(LnError::FailedToLink(e.to_string()).into()),
|
Err(e) => Err(LnError::FailedToLink(files[0].to_owned(), files[1].to_owned(), e.to_string()).into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue