Skip to content

Commit d429efc

Browse files
kbleesdscho
authored andcommitted
Win32: make FILETIME conversion functions public
Signed-off-by: Karsten Blees <[email protected]>
1 parent 4e2b20c commit d429efc

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
@@ -474,22 +474,6 @@ int mingw_chmod(const char *filename, int mode)
474474
return _wchmod(wfilename, mode);
475475
}
476476

477-
/*
478-
* The unit of FILETIME is 100-nanoseconds since January 1, 1601, UTC.
479-
* Returns the 100-nanoseconds ("hekto nanoseconds") since the epoch.
480-
*/
481-
static inline long long filetime_to_hnsec(const FILETIME *ft)
482-
{
483-
long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime;
484-
/* Windows to Unix Epoch conversion */
485-
return winTime - 116444736000000000LL;
486-
}
487-
488-
static inline time_t filetime_to_time_t(const FILETIME *ft)
489-
{
490-
return (time_t)(filetime_to_hnsec(ft) / 10000000);
491-
}
492-
493477
/* We keep the do_lstat code in a separate function to avoid recursion.
494478
* When a path ends with a slash, the stat will fail with ENOENT. In
495479
* 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
@@ -282,6 +282,22 @@ static inline int getrlimit(int resource, struct rlimit *rlp)
282282
return 0;
283283
}
284284

285+
/*
286+
* The unit of FILETIME is 100-nanoseconds since January 1, 1601, UTC.
287+
* Returns the 100-nanoseconds ("hekto nanoseconds") since the epoch.
288+
*/
289+
static inline long long filetime_to_hnsec(const FILETIME *ft)
290+
{
291+
long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime;
292+
/* Windows to Unix Epoch conversion */
293+
return winTime - 116444736000000000LL;
294+
}
295+
296+
static inline time_t filetime_to_time_t(const FILETIME *ft)
297+
{
298+
return (time_t)(filetime_to_hnsec(ft) / 10000000);
299+
}
300+
285301
/*
286302
* Use mingw specific stat()/lstat()/fstat() implementations on Windows.
287303
*/

0 commit comments

Comments
 (0)