diff options
author | KWSys Upstream <kwrobot@kitware.com> | 2018-11-28 12:11:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-11-28 13:56:00 (GMT) |
commit | cbc772b89d94d5c02c8739d4b428a3de52f4091b (patch) | |
tree | 23ab0b7c6bc895bf5ee24cb8daad6bcd872eaa15 | |
parent | 0bc20334bc16b1d72a0ae208a38c2a8afddd199e (diff) | |
download | CMake-cbc772b89d94d5c02c8739d4b428a3de52f4091b.zip CMake-cbc772b89d94d5c02c8739d4b428a3de52f4091b.tar.gz CMake-cbc772b89d94d5c02c8739d4b428a3de52f4091b.tar.bz2 |
KWSys 2018-11-28 (5ea12a52)
Code extracted from:
https://gitlab.kitware.com/utils/kwsys.git
at commit 5ea12a52b24248041adf49421a43df649530fc23 (master).
Upstream Shortlog
-----------------
Isaiah Norton (1):
4f9fb9aa SystemTools: Fix Touch to avoid requiring file ownership
-rw-r--r-- | SystemTools.cxx | 32 |
1 files changed, 4 insertions, 28 deletions
diff --git a/SystemTools.cxx b/SystemTools.cxx index 0a4ad7a..331f16e 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -1355,39 +1355,15 @@ bool SystemTools::Touch(const std::string& filename, bool create) } CloseHandle(h); #elif KWSYS_CXX_HAS_UTIMENSAT - struct timespec times[2] = { { 0, UTIME_OMIT }, { 0, UTIME_NOW } }; - if (utimensat(AT_FDCWD, filename.c_str(), times, 0) < 0) { + // utimensat is only available on newer Unixes and macOS 10.13+ + if (utimensat(AT_FDCWD, filename.c_str(), NULL, 0) < 0) { return false; } #else - struct stat st; - if (stat(filename.c_str(), &st) < 0) { - return false; - } - struct timeval mtime; - gettimeofday(&mtime, 0); -# if KWSYS_CXX_HAS_UTIMES - struct timeval atime; -# if KWSYS_CXX_STAT_HAS_ST_MTIM - atime.tv_sec = st.st_atim.tv_sec; - atime.tv_usec = st.st_atim.tv_nsec / 1000; -# elif KWSYS_CXX_STAT_HAS_ST_MTIMESPEC - atime.tv_sec = st.st_atimespec.tv_sec; - atime.tv_usec = st.st_atimespec.tv_nsec / 1000; -# else - atime.tv_sec = st.st_atime; - atime.tv_usec = 0; -# endif - struct timeval times[2] = { atime, mtime }; - if (utimes(filename.c_str(), times) < 0) { + // fall back to utimes + if (utimes(filename.c_str(), NULL) < 0) { return false; } -# else - struct utimbuf times = { st.st_atime, mtime.tv_sec }; - if (utime(filename.c_str(), ×) < 0) { - return false; - } -# endif #endif return true; } |