diff options
author | Brad King <brad.king@kitware.com> | 2018-12-06 13:38:17 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-12-06 13:38:23 (GMT) |
commit | 3542a553bf5149734c9002952795026ffbd06308 (patch) | |
tree | aa5b862b1c9189ae927db5c6f51ee0cd3bb0735c /Source | |
parent | d8c6427fa158a96a2e41f07d60c924cee94e413b (diff) | |
parent | 014a098479bbe091b47d20c070fb05bc362723c7 (diff) | |
download | CMake-3542a553bf5149734c9002952795026ffbd06308.zip CMake-3542a553bf5149734c9002952795026ffbd06308.tar.gz CMake-3542a553bf5149734c9002952795026ffbd06308.tar.bz2 |
Merge topic 'update-kwsys'
014a098479 Merge branch 'upstream-KWSys' into update-kwsys
cbc772b89d KWSys 2018-11-28 (5ea12a52)
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Isaiah <isaiah.norton@gmail.com>
Merge-request: !2678
Diffstat (limited to 'Source')
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 32 |
1 files changed, 4 insertions, 28 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 0a4ad7a..331f16e 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/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; } |