summaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-02-10 23:44:51 +0100
committerMax Kellermann <max@musicpd.org>2017-02-10 23:48:21 +0100
commit329c3ab21b7bc6ac735f5452b5ee2170499f69c1 (patch)
treef3adbca6fd2d4ae33625297604619506a2bda95c /src/fs
parent3b7f6641d2d4abb53496805477a9e11d3dd98fbd (diff)
fs/FileInfo: use std::chrono::system_clock
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/FileInfo.hxx19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/fs/FileInfo.hxx b/src/fs/FileInfo.hxx
index f82da8788..dd8f6be1a 100644
--- a/src/fs/FileInfo.hxx
+++ b/src/fs/FileInfo.hxx
@@ -24,14 +24,16 @@
#include "Path.hxx"
#include "system/Error.hxx"
-#include <stdint.h>
-
#ifdef WIN32
#include <fileapi.h>
#else
#include <sys/stat.h>
#endif
+#include <chrono>
+
+#include <stdint.h>
+
#ifdef WIN32
static inline constexpr uint64_t
@@ -47,6 +49,13 @@ FileTimeToTimeT(FILETIME ft)
- 116444736000000000) / 10000000;
}
+static std::chrono::system_clock::time_point
+FileTimeToChrono(FILETIME ft)
+{
+ // TODO: eliminate the time_t roundtrip, preserve sub-second resolution
+ return std::chrono::system_clock::from_time_t(FileTimeToTimeT(ft));
+}
+
#endif
class FileInfo {
@@ -100,11 +109,11 @@ public:
#endif
}
- time_t GetModificationTime() const {
+ std::chrono::system_clock::time_point GetModificationTime() const {
#ifdef WIN32
- return FileTimeToTimeT(data.ftLastWriteTime);
+ return FileTimeToChrono(data.ftLastWriteTime);
#else
- return st.st_mtime;
+ return std::chrono::system_clock::from_time_t(st.st_mtime);
#endif
}