diff options
author | Chris Wilson <chris+github@qwirx.com> | 2008-01-31 23:43:24 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2008-01-31 23:43:24 +0000 |
commit | 2ccdaf9a575f4cc0d758a87300b7cf51d96c9779 (patch) | |
tree | 7ab5878ef3b04c9566bd26ee2319cad2c4ae57a5 | |
parent | 71fc8d094e57a344d98984cf71f0a38c59ff9314 (diff) |
Add support for nanosecond timestamps in struct stat on Linux.
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | lib/common/FileModificationTime.h | 17 |
2 files changed, 14 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac index 85b8c968..07f7f3c8 100644 --- a/configure.ac +++ b/configure.ac @@ -159,6 +159,8 @@ AC_TYPE_SIZE_T 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> diff --git a/lib/common/FileModificationTime.h b/lib/common/FileModificationTime.h index a84df579..c64ca848 100644 --- a/lib/common/FileModificationTime.h +++ b/lib/common/FileModificationTime.h @@ -28,11 +28,18 @@ inline box_time_t FileModificationTime(struct stat &st) 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; |