summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2004-10-15 13:23:14 (GMT)
committerBrad King <brad.king@kitware.com>2004-10-15 13:23:14 (GMT)
commitb4176dcab91df1d7f28ee41e1f52eb6ae9accbf4 (patch)
treecb4c2b3b2f1905592f2c8ab16e79cd5a0a0cc16e /Source/cmSystemTools.cxx
parent4b20a7ad2d7ab259d75ac35309c8c27fbdc62f40 (diff)
downloadCMake-b4176dcab91df1d7f28ee41e1f52eb6ae9accbf4.zip
CMake-b4176dcab91df1d7f28ee41e1f52eb6ae9accbf4.tar.gz
CMake-b4176dcab91df1d7f28ee41e1f52eb6ae9accbf4.tar.bz2
ENH: Added FileTimeCompare method to compare file modification times. Currently the resolution is limited to one second.
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx30
1 files changed, 30 insertions, 0 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index d9f51f8..1e8bf2e 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1317,3 +1317,33 @@ bool cmSystemTools::PutEnv(const char* value)
return ret == 0;
}
+bool cmSystemTools::FileTimeCompare(const char* f1, const char* f2,
+ int* result)
+{
+ struct stat stat1, stat2;
+ if(stat(f1, &stat1) == 0 && stat(f2, &stat2) == 0)
+ {
+ *result = 0;
+ if(stat1.st_mtime < stat2.st_mtime)
+ {
+ *result = -1;
+ }
+ else if(stat1.st_mtime > stat2.st_mtime)
+ {
+ *result = 1;
+ }
+#if 0
+ // TODO: Support resolution higher than one second.
+ // Use st_mtim.tv_nsec if available and GetFileTime on Windows.
+ else if(stat1.st_mtim.tv_nsec < stat2.st_mtim.tv_nsec)
+ {
+ *result = 1;
+ }
+#endif
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}