From 912bff27f06a5b5909f3cb7607ab85c60b3ddc76 Mon Sep 17 00:00:00 2001 From: Dmitry Ilyin Date: Fri, 17 May 2019 11:38:48 +0300 Subject: [PATCH] yet another one revertion --- winpr/libwinpr/file/file.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/winpr/libwinpr/file/file.c b/winpr/libwinpr/file/file.c index aebd14266..e27c1158c 100644 --- a/winpr/libwinpr/file/file.c +++ b/winpr/libwinpr/file/file.c @@ -481,11 +481,12 @@ static BOOL FileUnlockFileEx(HANDLE hFile, DWORD dwReserved, DWORD nNumberOfByte return TRUE; } -static UINT64 FileTimeTo100ns(const FILETIME* ft) +static UINT64 FileTimeToUS(const FILETIME* ft) { - const UINT64 EPOCH_DIFF = 11644473600ULL * 10000000; + const UINT64 EPOCH_DIFF = 11644473600ULL * 1000000ULL; UINT64 tmp = ((UINT64)ft->dwHighDateTime) << 32 | ft->dwLowDateTime; + tmp /= 10; /* 100ns steps to 1us step */ tmp -= EPOCH_DIFF; return tmp; } @@ -533,13 +534,13 @@ static BOOL FileSetFileTime(HANDLE hFile, const FILETIME* lpCreationTime, } else { - UINT64 tmp = FileTimeTo100ns(lpLastAccessTime); + UINT64 tmp = FileTimeToUS(lpLastAccessTime); #if defined(ANDROID) || defined(__FreeBSD__) || defined(__APPLE__) || defined(KFREEBSD) - timevals[0].tv_sec = tmp / 10000000; - timevals[0].tv_usec = tmp % 10000000 / 10; + timevals[0].tv_sec = tmp / 1000000ULL; + timevals[0].tv_usec = tmp % 1000000ULL; #else - times[0].tv_sec = tmp / 10000000; - times[0].tv_nsec = tmp % 10000000 * 100; + times[0].tv_sec = tmp / 1000000ULL; + times[0].tv_nsec = (tmp % 1000000ULL) * 1000ULL; #endif } @@ -562,13 +563,13 @@ static BOOL FileSetFileTime(HANDLE hFile, const FILETIME* lpCreationTime, } else { - UINT64 tmp = FileTimeTo100ns(lpLastWriteTime); + UINT64 tmp = FileTimeToUS(lpLastWriteTime); #if defined(ANDROID) || defined(__FreeBSD__) || defined(__APPLE__) || defined(KFREEBSD) - timevals[1].tv_sec = tmp / 10000000; - timevals[1].tv_usec = tmp % 10000000 / 10; + timevals[1].tv_sec = tmp / 1000000ULL; + timevals[1].tv_usec = tmp % 1000000ULL; #else - times[1].tv_sec = tmp / 10000000; - times[1].tv_nsec = tmp % 10000000 * 100; + times[1].tv_sec = tmp / 1000000ULL; + times[1].tv_nsec = (tmp % 1000000ULL) * 1000ULL; #endif }