Skip to content

Commit f6a24d3

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

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
@@ -295,6 +295,22 @@ static inline int getrlimit(int resource, struct rlimit *rlp)
295295
return 0;
296296
}
297297

298+
/*
299+
* The unit of FILETIME is 100-nanoseconds since January 1, 1601, UTC.
300+
* Returns the 100-nanoseconds ("hekto nanoseconds") since the epoch.
301+
*/
302+
static inline long long filetime_to_hnsec(const FILETIME *ft)
303+
{
304+
long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime;
305+
/* Windows to Unix Epoch conversion */
306+
return winTime - 116444736000000000LL;
307+
}
308+
309+
static inline time_t filetime_to_time_t(const FILETIME *ft)
310+
{
311+
return (time_t)(filetime_to_hnsec(ft) / 10000000);
312+
}
313+
298314
/*
299315
* Use mingw specific stat()/lstat()/fstat() implementations on Windows.
300316
*/

0 commit comments

Comments
 (0)