aboutsummaryrefslogtreecommitdiff
path: root/butl/filesystem.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-12-05 18:59:56 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-12-05 18:59:56 +0200
commit6e04a1e8a6b38b123bbb98e38ff236b4a27d62cb (patch)
tree46d520c48067db7016388804e6ebbba58c4a634d /butl/filesystem.cxx
parentc4c350d940f0ca6bf5a57ee97e23dc0ecace0051 (diff)
Prevent signature clashes in nsec() overload set
Diffstat (limited to 'butl/filesystem.cxx')
-rw-r--r--butl/filesystem.cxx20
1 files changed, 13 insertions, 7 deletions
diff --git a/butl/filesystem.cxx b/butl/filesystem.cxx
index 5a43cd2..99417b1 100644
--- a/butl/filesystem.cxx
+++ b/butl/filesystem.cxx
@@ -140,28 +140,34 @@ namespace butl
return r;
}
- // Figuring out whether we have the nanoseconds in some form.
+ // Figuring out whether we have the nanoseconds in struct stat. Some
+ // platforms (e.g., FreeBSD), may provide some "compatibility" #define's,
+ // so use the second argument to not end up with the same signatures.
//
template <typename S>
- inline constexpr auto nsec (const S* s) -> decltype(s->st_mtim.tv_nsec)
+ inline constexpr auto
+ nsec (const S* s, bool) -> decltype(s->st_mtim.tv_nsec)
{
return s->st_mtim.tv_nsec; // POSIX (GNU/Linux, Solaris).
}
template <typename S>
- inline constexpr auto nsec (const S* s) -> decltype(s->st_mtimespec.tv_nsec)
+ inline constexpr auto
+ nsec (const S* s, int) -> decltype(s->st_mtimespec.tv_nsec)
{
- return s->st_mtimespec.tv_nsec; // MacOS X.
+ return s->st_mtimespec.tv_nsec; // *BSD, MacOS.
}
template <typename S>
- inline constexpr auto nsec (const S* s) -> decltype(s->st_mtime_n)
+ inline constexpr auto
+ nsec (const S* s, float) -> decltype(s->st_mtime_n)
{
return s->st_mtime_n; // AIX 5.2 and later.
}
template <typename S>
- inline constexpr int nsec (...) {return 0;}
+ inline constexpr int
+ nsec (...) {return 0;}
timestamp
file_mtime (const path& p)
@@ -178,7 +184,7 @@ namespace butl
return S_ISREG (s.st_mode)
? system_clock::from_time_t (s.st_mtime) +
chrono::duration_cast<duration> (
- chrono::nanoseconds (nsec<struct stat> (&s)))
+ chrono::nanoseconds (nsec<struct stat> (&s, true)))
: timestamp_nonexistent;
}