From e40482708b618ea533e4ce42f4e96e404f523698 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Sun, 30 Dec 2012 16:03:05 +0100 Subject: [PATCH] suppress warning about chown return value --- src/utils/copyfile.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/utils/copyfile.cpp b/src/utils/copyfile.cpp index 50bf6821..9c93c2e5 100644 --- a/src/utils/copyfile.cpp +++ b/src/utils/copyfile.cpp @@ -110,10 +110,14 @@ bool renameormove(const char *src, const char *dst, string &reason) // Try to preserve modes, owner, times. This may fail for a number // of reasons if ((st1.st_mode & 0777) != (st.st_mode & 0777)) { - chmod(dst, st.st_mode&0777); + if (chmod(dst, st.st_mode&0777) != 0) { + reason += string("Chmod ") + dst + "Error : " + strerror(errno); + } } if (st.st_uid != st1.st_uid || st.st_gid != st1.st_gid) { - chown(dst, st.st_uid, st.st_gid); + if (chown(dst, st.st_uid, st.st_gid) != 0) { + reason += string("Chown ") + dst + "Error : " + strerror(errno); + } } struct timeval times[2]; times[0].tv_sec = st.st_atime; @@ -192,9 +196,13 @@ int main(int argc, const char **argv) if (!ret) { cerr << reason << endl; exit(1); - } - exit(0); + } else { + cout << "Succeeded" << endl; + if (!reason.empty()) { + cout << "Warnings: " << reason << endl; + } + exit(0); + } } - #endif