Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 52fa661

Browse files
kbleeskasal
authored andcommitted
Win32: make FILETIME conversion functions public
Signed-off-by: Karsten Blees <[email protected]>
1 parent cd0792a commit 52fa661

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

compat/mingw.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -418,22 +418,6 @@ int mingw_chmod(const char *filename, int mode)
418418
return _wchmod(wfilename, mode);
419419
}
420420

421-
/*
422-
* The unit of FILETIME is 100-nanoseconds since January 1, 1601, UTC.
423-
* Returns the 100-nanoseconds ("hekto nanoseconds") since the epoch.
424-
*/
425-
static inline long long filetime_to_hnsec(const FILETIME *ft)
426-
{
427-
long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime;
428-
/* Windows to Unix Epoch conversion */
429-
return winTime - 116444736000000000LL;
430-
}
431-
432-
static inline time_t filetime_to_time_t(const FILETIME *ft)
433-
{
434-
return (time_t)(filetime_to_hnsec(ft) / 10000000);
435-
}
436-
437421
/* We keep the do_lstat code in a separate function to avoid recursion.
438422
* When a path ends with a slash, the stat will fail with ENOENT. In
439423
* this case, we strip the trailing slashes and stat again.

compat/mingw.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,22 @@ static inline int getrlimit(int resource, struct rlimit *rlp)
274274
return 0;
275275
}
276276

277+
/*
278+
* The unit of FILETIME is 100-nanoseconds since January 1, 1601, UTC.
279+
* Returns the 100-nanoseconds ("hekto nanoseconds") since the epoch.
280+
*/
281+
static inline long long filetime_to_hnsec(const FILETIME *ft)
282+
{
283+
long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime;
284+
/* Windows to Unix Epoch conversion */
285+
return winTime - 116444736000000000LL;
286+
}
287+
288+
static inline time_t filetime_to_time_t(const FILETIME *ft)
289+
{
290+
return (time_t)(filetime_to_hnsec(ft) / 10000000);
291+
}
292+
277293
/*
278294
* Use mingw specific stat()/lstat()/fstat() implementations on Windows.
279295
*/

0 commit comments

Comments
 (0)