mirror of
https://github.com/git-for-windows/git.git
synced 2026-04-22 02:54:28 -05:00
Win32: make FILETIME conversion functions public
We will use them in the upcoming "FSCache" patches (to accelerate sequential lstat() calls). Signed-off-by: Karsten Blees <blees@dcon.de> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
committed by
Johannes Schindelin
parent
a11a8ac24a
commit
4619239ea1
@@ -788,24 +788,6 @@ int mingw_chmod(const char *filename, int mode)
|
|||||||
return _wchmod(wfilename, mode);
|
return _wchmod(wfilename, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* The unit of FILETIME is 100-nanoseconds since January 1, 1601, UTC.
|
|
||||||
* Returns the 100-nanoseconds ("hekto nanoseconds") since the epoch.
|
|
||||||
*/
|
|
||||||
static inline long long filetime_to_hnsec(const FILETIME *ft)
|
|
||||||
{
|
|
||||||
long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime;
|
|
||||||
/* Windows to Unix Epoch conversion */
|
|
||||||
return winTime - 116444736000000000LL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void filetime_to_timespec(const FILETIME *ft, struct timespec *ts)
|
|
||||||
{
|
|
||||||
long long hnsec = filetime_to_hnsec(ft);
|
|
||||||
ts->tv_sec = (time_t)(hnsec / 10000000);
|
|
||||||
ts->tv_nsec = (hnsec % 10000000) * 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies that safe_create_leading_directories() would succeed.
|
* Verifies that safe_create_leading_directories() would succeed.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -356,6 +356,17 @@ static inline int getrlimit(int resource, struct rlimit *rlp)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The unit of FILETIME is 100-nanoseconds since January 1, 1601, UTC.
|
||||||
|
* Returns the 100-nanoseconds ("hekto nanoseconds") since the epoch.
|
||||||
|
*/
|
||||||
|
static inline long long filetime_to_hnsec(const FILETIME *ft)
|
||||||
|
{
|
||||||
|
long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime;
|
||||||
|
/* Windows to Unix Epoch conversion */
|
||||||
|
return winTime - 116444736000000000LL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use mingw specific stat()/lstat()/fstat() implementations on Windows,
|
* Use mingw specific stat()/lstat()/fstat() implementations on Windows,
|
||||||
* including our own struct stat with 64 bit st_size and nanosecond-precision
|
* including our own struct stat with 64 bit st_size and nanosecond-precision
|
||||||
@@ -372,6 +383,13 @@ struct timespec {
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static inline void filetime_to_timespec(const FILETIME *ft, struct timespec *ts)
|
||||||
|
{
|
||||||
|
long long hnsec = filetime_to_hnsec(ft);
|
||||||
|
ts->tv_sec = (time_t)(hnsec / 10000000);
|
||||||
|
ts->tv_nsec = (hnsec % 10000000) * 100;
|
||||||
|
}
|
||||||
|
|
||||||
struct mingw_stat {
|
struct mingw_stat {
|
||||||
_dev_t st_dev;
|
_dev_t st_dev;
|
||||||
_ino_t st_ino;
|
_ino_t st_ino;
|
||||||
|
|||||||
Reference in New Issue
Block a user