From 40c5e184816f70e76486f8fbbd355bd7ab5f06b1 Mon Sep 17 00:00:00 2001 From: Willi Goesgens Date: Tue, 14 Apr 2015 17:16:44 +0200 Subject: [PATCH] - We _must_ evaluate the return values of these system calls. - fix windows driveletter detection. --- lib/Basics/files.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/Basics/files.cpp b/lib/Basics/files.cpp index e1dc43d9d9..e79d332abb 100644 --- a/lib/Basics/files.cpp +++ b/lib/Basics/files.cpp @@ -546,7 +546,7 @@ int TRI_CreateRecursiveDirectory (char const* path, if ((p - s > 0) #ifdef _WIN32 && // Don't try to create the drive letter as directory: - (s - copy == 2) && + (p - copy == 2) && (s[1] == ':') #endif ) { @@ -1900,13 +1900,25 @@ bool TRI_CopyFile (std::string const& src, std::string const& dst, std::string & times[0].tv_sec = statbuf.st_atim.tv_sec; times[1].tv_sec = statbuf.st_mtim.tv_sec; - fchown(dstFD, -1 /*statbuf.st_uid*/, statbuf.st_gid); - fchmod(dstFD, statbuf.st_mode); + if (fchown(dstFD, -1 /*statbuf.st_uid*/, statbuf.st_gid) != 0) { + error = std::string("failed to chown ") + dst + ": " + strerror(errno); + //rc = false; no, this is not fatal... + } + if (fchmod(dstFD, statbuf.st_mode) != 0) { + error = std::string("failed to chmod ") + dst + ": " + strerror(errno); + rc = false; + } #ifdef HAVE_FUTIMES - futimes(dstFD, times); + if (futimes(dstFD, times) != 0) { + error = std::string("failed to adjust age: ") + dst + ": " + strerror(errno); + rc = false; + } #else - utimes(dst.c_str(), times); + if (utimes(dst.c_str(), times) != 0) { + error = std::string("failed to adjust age: ") + dst + ": " + strerror(errno); + rc = false; + } #endif close(srcFD); close(dstFD); @@ -1941,7 +1953,7 @@ bool TRI_CopyAttributes(std::string srcItem, std::string dstItem, std::string &e if ( utimes(dstItem.c_str(), times) != 0) { - error = std::string("failed to adjust age utimes ") + dstItem + ": " + strerror(errno); + error = std::string("failed to adjust age: ") + dstItem + ": " + strerror(errno); return false; }