mirror of
https://git.mirrors.martin98.com/https://github.com/gulrak/filesystem
synced 2025-07-23 23:44:30 +08:00
Fix a Y2038 bug in timeToFILETIME
The old code truncated time_t to a 32-bit value when using Int32x32To64. This example code has been fixed on MSDN a while ago, so this change only updates it to the current version. More on this issue: https://cookieplmonster.github.io/2022/02/17/year-2038-problem/
This commit is contained in:
parent
cd6805e94d
commit
4f0824fd76
@ -2241,10 +2241,10 @@ GHC_INLINE time_t timeFromFILETIME(const FILETIME& ft)
|
||||
|
||||
GHC_INLINE void timeToFILETIME(time_t t, FILETIME& ft)
|
||||
{
|
||||
LONGLONG ll;
|
||||
ll = Int32x32To64(t, 10000000) + 116444736000000000;
|
||||
ft.dwLowDateTime = static_cast<DWORD>(ll);
|
||||
ft.dwHighDateTime = static_cast<DWORD>(ll >> 32);
|
||||
ULARGE_INTEGER ull;
|
||||
ull.QuadPart = static_cast<ULONGLONG>((t * 10000000LL) + 116444736000000000LL);
|
||||
ft.dwLowDateTime = ull.LowPart;
|
||||
ft.dwHighDateTime = ull.HighPart;
|
||||
}
|
||||
|
||||
template <typename INFO>
|
||||
|
Loading…
x
Reference in New Issue
Block a user