mirror of
https://git.mirrors.martin98.com/https://github.com/gulrak/filesystem
synced 2025-07-24 09:14:25 +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)
|
GHC_INLINE void timeToFILETIME(time_t t, FILETIME& ft)
|
||||||
{
|
{
|
||||||
LONGLONG ll;
|
ULARGE_INTEGER ull;
|
||||||
ll = Int32x32To64(t, 10000000) + 116444736000000000;
|
ull.QuadPart = static_cast<ULONGLONG>((t * 10000000LL) + 116444736000000000LL);
|
||||||
ft.dwLowDateTime = static_cast<DWORD>(ll);
|
ft.dwLowDateTime = ull.LowPart;
|
||||||
ft.dwHighDateTime = static_cast<DWORD>(ll >> 32);
|
ft.dwHighDateTime = ull.HighPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename INFO>
|
template <typename INFO>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user