X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;ds=sidebyside;f=os%2Fwindows%2Fposix.c;h=3388127821acadc5d4053689f1246efd3be96af3;hb=1f086b55e7480b0926177576f36813b8b9eb4a61;hp=41fc480df9f14f92a75ff07a5fda30fa098deb06;hpb=ba55bfa90dbbc4a1432d6855c8411663448f19d2;p=fio.git diff --git a/os/windows/posix.c b/os/windows/posix.c index 41fc480d..33881278 100755 --- a/os/windows/posix.c +++ b/os/windows/posix.c @@ -232,10 +232,12 @@ char *dlerror(void) /* Copied from http://blogs.msdn.com/b/joshpoley/archive/2007/12/19/date-time-formats-and-conversions.aspx */ void Time_tToSystemTime(time_t dosTime, SYSTEMTIME *systemTime) { - LARGE_INTEGER jan1970FT; - LARGE_INTEGER utcFT; - jan1970FT.QuadPart = 116444736000000000LL; // january 1st 1970 - utcFT.QuadPart = ((unsigned __int64)dosTime) * 10000000 + jan1970FT.QuadPart; + FILETIME utcFT; + LONGLONG jan1970; + + jan1970 = Int32x32To64(dosTime, 10000000) + 116444736000000000; + utcFT.dwLowDateTime = (DWORD)jan1970; + utcFT.dwHighDateTime = jan1970 >> 32; FileTimeToSystemTime((FILETIME*)&utcFT, systemTime); } @@ -243,12 +245,12 @@ void Time_tToSystemTime(time_t dosTime, SYSTEMTIME *systemTime) char* ctime_r(const time_t *t, char *buf) { SYSTEMTIME systime; - const char * const dayOfWeek[] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" }; + const char * const dayOfWeek[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; const char * const monthOfYear[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; Time_tToSystemTime(*t, &systime); /* We don't know how long `buf` is, but assume it's rounded up from the minimum of 25 to 32 */ - StringCchPrintfA(buf, 32, "%s %s %d %02d:%02d:%02d %04d", dayOfWeek[systime.wDayOfWeek - 1], monthOfYear[systime.wMonth - 1], + StringCchPrintfA(buf, 31, "%s %s %d %02d:%02d:%02d %04d\n", dayOfWeek[systime.wDayOfWeek % 7], monthOfYear[(systime.wMonth - 1) % 12], systime.wDay, systime.wHour, systime.wMinute, systime.wSecond, systime.wYear); return buf; } @@ -888,7 +890,7 @@ struct dirent *readdir(DIR *dirp) if (dirp->find_handle == INVALID_HANDLE_VALUE) { char search_pattern[MAX_PATH]; - StringCchPrintfA(search_pattern, MAX_PATH, "%s\\*", dirp->dirname); + StringCchPrintfA(search_pattern, MAX_PATH-1, "%s\\*", dirp->dirname); dirp->find_handle = FindFirstFileA(search_pattern, &find_data); if (dirp->find_handle == INVALID_HANDLE_VALUE) return NULL;