| 1525 | } |
| 1526 | |
| 1527 | inline DWORD to_FILETIME(std::time_t t, FILETIME& ft) |
| 1528 | { |
| 1529 | // On Windows, time_t is signed, and negative values are possible since FILETIME epoch is earlier than POSIX epoch |
| 1530 | int64_t st = static_cast< int64_t >(t); |
| 1531 | if (BOOST_UNLIKELY(st < ((std::numeric_limits< int64_t >::min)() / 10000000 - 11644473600ll) || |
| 1532 | st > ((std::numeric_limits< int64_t >::max)() / 10000000 - 11644473600ll))) |
| 1533 | { |
| 1534 | return ERROR_INVALID_DATA; |
| 1535 | } |
| 1536 | |
| 1537 | st = (st + 11644473600ll) * 10000000; |
| 1538 | uint64_t ut = static_cast< uint64_t >(st); |
| 1539 | ft.dwLowDateTime = static_cast< DWORD >(ut); |
| 1540 | ft.dwHighDateTime = static_cast< DWORD >(ut >> 32u); |
| 1541 | |
| 1542 | return 0u; |
| 1543 | } |
| 1544 | |
| 1545 | } // unnamed namespace |
| 1546 | |