# HG changeset patch # User Michael Pavone # Date 1461377895 25200 # Node ID fd7702bcc034fe1466813ea1851ac4eae9ac3668 # Parent fbd783ccbadb520418742c1a85301626ffc1e4f3 FindFirstFile makes more sense for getting modification times of a path than using CreateFile and GetFileTimes diff -r fbd783ccbadb -r fd7702bcc034 util.c --- a/util.c Fri Apr 22 09:20:01 2016 -0700 +++ b/util.c Fri Apr 22 19:18:15 2016 -0700 @@ -286,23 +286,19 @@ time_t get_modification_time(char *path) { - HANDLE file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); - if (file == INVALID_HANDLE_VALUE) { + HANDLE results; + WIN32_FIND_DATA file; + results = FindFirstFile(path, &file); + if (results == INVALID_HANDLE_VALUE) { return 0; } - FILETIME ft; - uint8_t ret = GetFileTime(file, NULL, NULL, &ft); - CloseHandle(file); - if (ret) { - uint64_t wintime = ((uint64_t)ft.dwHighDateTime) << 32 | ft.dwLowDateTime; - //convert to seconds - wintime /= 10000000; - //adjust for difference between Windows and Unix Epoch - wintime -= 11644473600LL; - return (time_t)wintime; - } else { - return 0; - } + FindClose(results); + uint64_t wintime = ((uint64_t)file.ftLastWriteTime.dwHighDateTime) << 32 | file.ftLastWriteTime.dwLowDateTime; + //convert to seconds + wintime /= 10000000; + //adjust for difference between Windows and Unix Epoch + wintime -= 11644473600LL; + return (time_t)wintime; } int ensure_dir_exists(char *path)