windows: get rid of overly complicated uv_filetime_to_time_t helper
This commit is contained in:
parent
d169ba1a1b
commit
ea3e2cd480
@ -91,6 +91,9 @@
|
||||
return; \
|
||||
}
|
||||
|
||||
#define FILETIME_TO_TIME_T(filetime) \
|
||||
((*((uint64_t*) &(filetime)) - 116444736000000000ULL) / 10000000ULL);
|
||||
|
||||
#define IS_SLASH(c) ((c) == L'\\' || (c) == L'/')
|
||||
#define IS_LETTER(c) (((c) >= L'a' && (c) <= L'z') || \
|
||||
((c) >= L'A' && (c) <= L'Z'))
|
||||
@ -630,9 +633,9 @@ static void fs__stat(uv_fs_t* req, const wchar_t* path, int link) {
|
||||
(int64_t) info.nFileSizeLow;
|
||||
}
|
||||
|
||||
uv_filetime_to_time_t(&info.ftLastWriteTime, &(req->stat.st_mtime));
|
||||
uv_filetime_to_time_t(&info.ftLastAccessTime, &(req->stat.st_atime));
|
||||
uv_filetime_to_time_t(&info.ftCreationTime, &(req->stat.st_ctime));
|
||||
req->stat.st_mtime = FILETIME_TO_TIME_T(info.ftLastWriteTime);
|
||||
req->stat.st_atime = FILETIME_TO_TIME_T(info.ftLastAccessTime);
|
||||
req->stat.st_ctime = FILETIME_TO_TIME_T(info.ftCreationTime);
|
||||
|
||||
req->stat.st_nlink = (info.nNumberOfLinks <= SHRT_MAX) ?
|
||||
(short) info.nNumberOfLinks : SHRT_MAX;
|
||||
|
||||
@ -280,7 +280,6 @@ void uv__fs_poll_endgame(uv_loop_t* loop, uv_fs_poll_t* handle);
|
||||
void uv__util_init();
|
||||
|
||||
int uv_parent_pid();
|
||||
void uv_filetime_to_time_t(FILETIME* file_time, time_t* stat_time);
|
||||
void uv_fatal_error(const int errorno, const char* syscall);
|
||||
uv_err_code uv_translate_sys_error(int sys_errno);
|
||||
|
||||
|
||||
@ -862,26 +862,3 @@ void uv_free_interface_addresses(uv_interface_address_t* addresses,
|
||||
|
||||
free(addresses);
|
||||
}
|
||||
|
||||
|
||||
void uv_filetime_to_time_t(FILETIME* file_time, time_t* stat_time) {
|
||||
FILETIME local_time;
|
||||
SYSTEMTIME system_time;
|
||||
struct tm time;
|
||||
|
||||
if ((file_time->dwLowDateTime || file_time->dwHighDateTime) &&
|
||||
FileTimeToLocalFileTime(file_time, &local_time) &&
|
||||
FileTimeToSystemTime(&local_time, &system_time)) {
|
||||
time.tm_year = system_time.wYear - 1900;
|
||||
time.tm_mon = system_time.wMonth - 1;
|
||||
time.tm_mday = system_time.wDay;
|
||||
time.tm_hour = system_time.wHour;
|
||||
time.tm_min = system_time.wMinute;
|
||||
time.tm_sec = system_time.wSecond;
|
||||
time.tm_isdst = -1;
|
||||
|
||||
*stat_time = mktime(&time);
|
||||
} else {
|
||||
*stat_time = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user