diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:14:37 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:14:37 +0200 |
commit | 8bf668665b107469086f16cb8ad23e47d479d2b4 (patch) | |
tree | 66a91ef06a8caa7cd6819dcbe1860693d3eda8d5 /shared/int64.h | |
parent | 3.21 (diff) | |
download | FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.tar.gz FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.tar.bz2 FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.zip |
4.0
Diffstat (limited to 'shared/int64.h')
-rw-r--r-- | shared/int64.h | 23 |
1 files changed, 22 insertions, 1 deletions
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<boost::uint64_t>(number.value); return UInt64(number.value); } template <> inline Int64 to(UInt64 number) { checkRange<boost:: int64_t>(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<Int64>(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<UInt64>(utcTime + Int64(3054539008UL, 2)) * 10000000U; + const FILETIME output = { fileTimeLong.getLo(), fileTimeLong.getHi() }; + return output; +} +#endif } |