system/Clock, fs/FileInfo: move FILETIME specific code to time/FileTime.hxx

This commit is contained in:
Max Kellermann
2019-05-08 15:47:04 +02:00
parent 96f889276f
commit 5641c4baa6
3 changed files with 75 additions and 38 deletions

View File

@@ -24,7 +24,7 @@
#include "system/Error.hxx"
#ifdef _WIN32
#include <fileapi.h>
#include "time/FileTime.hxx"
#else
#include <sys/stat.h>
#endif
@@ -33,30 +33,6 @@
#include <stdint.h>
#ifdef _WIN32
static constexpr uint64_t
ConstructUint64(DWORD lo, DWORD hi)
{
return uint64_t(lo) | (uint64_t(hi) << 32);
}
static constexpr time_t
FileTimeToTimeT(FILETIME ft)
{
return (ConstructUint64(ft.dwLowDateTime, ft.dwHighDateTime)
- 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 {
friend bool GetFileInfo(Path path, FileInfo &info,
bool follow_symlinks);