summaryrefslogtreecommitdiffstats
path: root/SystemTools.cxx
diff options
context:
space:
mode:
authorKWSys Robot <kwrobot@kitware.com>2015-10-06 14:29:47 (GMT)
committerBrad King <brad.king@kitware.com>2015-10-08 17:26:04 (GMT)
commit13c22d280e3b4d4f73e607617d18a3d55b509099 (patch)
tree3967f5a460472d7e70562a7516ff4df9a888980e /SystemTools.cxx
parentbca73252130b7f60fc12b7bcbbc95a3153047bd3 (diff)
downloadCMake-13c22d280e3b4d4f73e607617d18a3d55b509099.zip
CMake-13c22d280e3b4d4f73e607617d18a3d55b509099.tar.gz
CMake-13c22d280e3b4d4f73e607617d18a3d55b509099.tar.bz2
KWSys 2015-10-06 (ed82989c)
Extract upstream KWSys using the following shell commands. $ git archive --prefix=upstream-kwsys/ ed82989c | tar x $ git shortlog --no-merges --abbrev=8 --format='%h %s' d79801bb..ed82989c Brad King (3): 9baab632 SystemTools: Keep stat st_mtim field existence private 39475e20 SystemTools: Refactor utimes invocation ed82989c SystemTools: Implement nanosecond file times on OS X
Diffstat (limited to 'SystemTools.cxx')
-rw-r--r--SystemTools.cxx37
1 files changed, 29 insertions, 8 deletions
diff --git a/SystemTools.cxx b/SystemTools.cxx
index 262af27..da34eb9 100644
--- a/SystemTools.cxx
+++ b/SystemTools.cxx
@@ -1366,15 +1366,18 @@ bool SystemTools::Touch(const std::string& filename, bool create)
struct timeval mtime;
gettimeofday(&mtime, 0);
# if KWSYS_CXX_HAS_UTIMES
- struct timeval times[2] =
- {
-# if KWSYS_STAT_HAS_ST_MTIM
- {st.st_atim.tv_sec, st.st_atim.tv_nsec/1000}, /* tv_sec, tv_usec */
+ 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
- {st.st_atime, 0},
+ atime.tv_sec = st.st_atime;
+ atime.tv_usec = 0;
# endif
- mtime
- };
+ struct timeval times[2] = { atime, mtime };
if(utimes(filename.c_str(), times) < 0)
{
return false;
@@ -1408,7 +1411,7 @@ bool SystemTools::FileTimeCompare(const std::string& f1,
{
return false;
}
-# if KWSYS_STAT_HAS_ST_MTIM
+# if KWSYS_CXX_STAT_HAS_ST_MTIM
// Compare using nanosecond resolution.
if(s1.st_mtim.tv_sec < s2.st_mtim.tv_sec)
{
@@ -1426,6 +1429,24 @@ bool SystemTools::FileTimeCompare(const std::string& f1,
{
*result = 1;
}
+# elif KWSYS_CXX_STAT_HAS_ST_MTIMESPEC
+ // Compare using nanosecond resolution.
+ if(s1.st_mtimespec.tv_sec < s2.st_mtimespec.tv_sec)
+ {
+ *result = -1;
+ }
+ else if(s1.st_mtimespec.tv_sec > s2.st_mtimespec.tv_sec)
+ {
+ *result = 1;
+ }
+ else if(s1.st_mtimespec.tv_nsec < s2.st_mtimespec.tv_nsec)
+ {
+ *result = -1;
+ }
+ else if(s1.st_mtimespec.tv_nsec > s2.st_mtimespec.tv_nsec)
+ {
+ *result = 1;
+ }
# else
// Compare using 1 second resolution.
if(s1.st_mtime < s2.st_mtime)