From d5fe880a57bc140f2e1469d2f1c75f815df94eff Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Wed, 13 Feb 2008 16:52:00 +0000 Subject: cp: add ENABLE_FEATURE_VERBOSE_CP_MESSAGE. Closes bug 1470 --- libbb/copy_file.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'libbb/copy_file.c') diff --git a/libbb/copy_file.c b/libbb/copy_file.c index 3da8a3531..d37d51562 100644 --- a/libbb/copy_file.c +++ b/libbb/copy_file.c @@ -29,6 +29,7 @@ // for POSIX mode to give reasonable error message static int ask_and_unlink(const char *dest, int flags) { + int e = errno; #if DO_POSIX_CP if (!(flags & (FILEUTILS_FORCE|FILEUTILS_INTERACTIVE))) { // Either it exists, or the *path* doesnt exist @@ -50,7 +51,16 @@ static int ask_and_unlink(const char *dest, int flags) return 0; // not allowed to overwrite } if (unlink(dest) < 0) { - bb_perror_msg("cannot remove '%s'", dest); +#if ENABLE_FEATURE_VERBOSE_CP_MESSAGE + if (e == errno && e == ENOENT) { + /* e == ENOTDIR is similar: path has non-dir component, + * but in this case we don't even reach copy_file() */ + bb_error_msg("cannot create '%s': Path does not exist", dest); + return -1; // error + } +#endif + errno = e; + bb_perror_msg("cannot create '%s'", dest); return -1; // error } return 1; // ok (to try again) -- cgit v1.2.3