[Box Backup-commit] COMMIT r2080 - in box/trunk: . lib/common
boxbackup-dev@fluffy.co.uk
boxbackup-dev@fluffy.co.uk
Thu, 31 Jan 2008 23:43:24 +0000 (UTC)
Author: chris
Date: 2008-01-31 23:43:24 +0000 (Thu, 31 Jan 2008)
New Revision: 2080
Modified:
box/trunk/configure.ac
box/trunk/lib/common/FileModificationTime.h
Log:
Add support for nanosecond timestamps in struct stat on Linux.
Modified: box/trunk/configure.ac
===================================================================
--- box/trunk/configure.ac 2008-01-31 23:42:46 UTC (rev 2079)
+++ box/trunk/configure.ac 2008-01-31 23:43:24 UTC (rev 2080)
@@ -159,6 +159,8 @@
AC_CHECK_MEMBERS([struct stat.st_flags])
AC_CHECK_MEMBERS([struct stat.st_mtimespec])
+AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec])
+AC_CHECK_MEMBERS([struct stat.st_atimensec])
AC_CHECK_MEMBERS([struct sockaddr_in.sin_len],,, [[
#include <sys/types.h>
#include <netinet/in.h>
Modified: box/trunk/lib/common/FileModificationTime.h
===================================================================
--- box/trunk/lib/common/FileModificationTime.h 2008-01-31 23:42:46 UTC (rev 2079)
+++ box/trunk/lib/common/FileModificationTime.h 2008-01-31 23:43:24 UTC (rev 2080)
@@ -28,11 +28,18 @@
inline box_time_t FileAttrModificationTime(struct stat &st)
{
-#ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC
- box_time_t statusmodified = ((int64_t)st.st_ctime) * (MICRO_SEC_IN_SEC_LL);
-#else
- box_time_t statusmodified = (((int64_t)st.st_ctimespec.tv_nsec) / NANO_SEC_IN_USEC_LL)
- + (((int64_t)st.st_ctimespec.tv_sec) * (MICRO_SEC_IN_SEC_LL));
+ box_time_t statusmodified =
+#ifdef HAVE_STRUCT_STAT_ST_MTIMESPEC
+ (((int64_t)st.st_ctimespec.tv_nsec) / (NANO_SEC_IN_USEC_LL)) +
+ (((int64_t)st.st_ctimespec.tv_sec) * (MICRO_SEC_IN_SEC_LL));
+#elif defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC
+ (((int64_t)st.st_ctim.tv_nsec) / (NANO_SEC_IN_USEC_LL)) +
+ (((int64_t)st.st_ctim.tv_sec) * (MICRO_SEC_IN_SEC_LL));
+#elif defined HAVE_STRUCT_STAT_ST_ATIMENSEC
+ (((int64_t)st.st_ctimensec) / (NANO_SEC_IN_USEC_LL)) +
+ (((int64_t)st.st_ctime) * (MICRO_SEC_IN_SEC_LL));
+#else // no nanoseconds anywhere
+ (((int64_t)st.st_ctime) * (MICRO_SEC_IN_SEC_LL));
#endif
return statusmodified;