summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/PlaylistFile.cxx2
-rw-r--r--src/SongUpdate.cxx2
-rw-r--r--src/db/plugins/simple/SimpleDatabasePlugin.cxx4
-rw-r--r--src/fs/FileInfo.hxx19
-rw-r--r--src/storage/plugins/LocalStorage.cxx2
5 files changed, 19 insertions, 10 deletions
diff --git a/src/PlaylistFile.cxx b/src/PlaylistFile.cxx
index d9846044e..ec66cacf4 100644
--- a/src/PlaylistFile.cxx
+++ b/src/PlaylistFile.cxx
@@ -148,7 +148,7 @@ LoadPlaylistFileInfo(PlaylistInfo &info,
return false;
info.name = std::move(name_utf8);
- info.mtime = fi.GetModificationTime();
+ info.mtime = std::chrono::system_clock::to_time_t(fi.GetModificationTime());
return true;
}
diff --git a/src/SongUpdate.cxx b/src/SongUpdate.cxx
index 1075c09df..8913fea14 100644
--- a/src/SongUpdate.cxx
+++ b/src/SongUpdate.cxx
@@ -151,7 +151,7 @@ DetachedSong::LoadFile(Path path)
if (!tag_file_scan(path, tag_builder))
return false;
- mtime = fi.GetModificationTime();
+ mtime = std::chrono::system_clock::to_time_t(fi.GetModificationTime());
tag_builder.Commit(tag);
return true;
}
diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.cxx b/src/db/plugins/simple/SimpleDatabasePlugin.cxx
index cfa335416..6395c81bb 100644
--- a/src/db/plugins/simple/SimpleDatabasePlugin.cxx
+++ b/src/db/plugins/simple/SimpleDatabasePlugin.cxx
@@ -157,7 +157,7 @@ SimpleDatabase::Load()
FileInfo fi;
if (GetFileInfo(path, fi))
- mtime = fi.GetModificationTime();
+ mtime = std::chrono::system_clock::to_time_t(fi.GetModificationTime());
}
void
@@ -358,7 +358,7 @@ SimpleDatabase::Save()
FileInfo fi;
if (GetFileInfo(path, fi))
- mtime = fi.GetModificationTime();
+ mtime = std::chrono::system_clock::to_time_t(fi.GetModificationTime());
}
void
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
}
diff --git a/src/storage/plugins/LocalStorage.cxx b/src/storage/plugins/LocalStorage.cxx
index 59e0c34f3..057b34ab7 100644
--- a/src/storage/plugins/LocalStorage.cxx
+++ b/src/storage/plugins/LocalStorage.cxx
@@ -86,7 +86,7 @@ Stat(Path path, bool follow)
info.type = StorageFileInfo::Type::OTHER;
info.size = src.GetSize();
- info.mtime = src.GetModificationTime();
+ info.mtime = std::chrono::system_clock::to_time_t(src.GetModificationTime());
#ifdef WIN32
info.device = info.inode = 0;
#else