From 8bf668665b107469086f16cb8ad23e47d479d2b4 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:14:37 +0200 Subject: 4.0 --- shared/int64.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'shared/int64.h') diff --git a/shared/int64.h b/shared/int64.h index 61ef1716..cfd3e3d1 100644 --- a/shared/int64.h +++ b/shared/int64.h @@ -120,7 +120,6 @@ inline Int64 operator<<(const Int64& lhs, int rhs) { return Int64(lhs) <<= rhs; inline Int64 operator>>(const Int64& lhs, int rhs) { return Int64(lhs) >>= rhs; } - class UInt64 { struct DummyClass { operator size_t() { return 0U; } }; @@ -201,6 +200,28 @@ inline UInt64 operator>>(const UInt64& lhs, int rhs) { return UInt64(lhs) >>= rh template <> inline UInt64 to(Int64 number) { checkRange(number.value); return UInt64(number.value); } template <> inline Int64 to(UInt64 number) { checkRange(number.value); return Int64(number.value); } + + +#ifdef FFS_WIN +//convert FILETIME (number of 100-nanosecond intervals since January 1, 1601 UTC) +// to time_t (number of seconds since Jan. 1st 1970 UTC) +// +//FAT32 time is preserved exactly: FAT32 -> toTimeT -> tofiletime -> FAT32 +inline +Int64 toTimeT(const FILETIME& ft) +{ + return to(UInt64(ft.dwLowDateTime, ft.dwHighDateTime) / 10000000U) - Int64(3054539008UL, 2); + //timeshift between ansi C time and FILETIME in seconds == 11644473600s +} + +inline +FILETIME tofiletime(const Int64& utcTime) +{ + const UInt64 fileTimeLong = to(utcTime + Int64(3054539008UL, 2)) * 10000000U; + const FILETIME output = { fileTimeLong.getLo(), fileTimeLong.getHi() }; + return output; +} +#endif } -- cgit