[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
futimens() for WIN32/MinGW
From: |
Tim Rühsen |
Subject: |
futimens() for WIN32/MinGW |
Date: |
Tue, 4 Apr 2017 13:03:12 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 |
Hi,
gnulib has no support for WIN32 futimens resp. the gnulib implementation
returns a 'not implemented' error.
So today I wrote a surrogate for it, which works for me on MinGW.
Since I am not sure where to add it (futimens.c or utimens.c) and if
there are caveats, I ask you to add it where appropriate.
#ifdef _WIN32
#include <windows.h>
int futimens(int fd, const struct timespec times[2])
{
FILETIME mt, at;
LONGLONG ll;
// convert time_t to FILETIME
ll = Int32x32To64(times[0].tv_sec, 10000000) + 116444736000000000;
at.dwLowDateTime = (DWORD) ll;
at.dwHighDateTime = ll >> 32;
ll = Int32x32To64(times[1].tv_sec, 10000000) + 116444736000000000;
mt.dwLowDateTime = (DWORD) ll;
mt.dwHighDateTime = ll >> 32;
BOOL success = SetFileTime(
(HANDLE) _get_osfhandle (fd),
&mt, // creation
&at, // last access
&mt); // last modification
return success ? 0 : -1;
}
#endif
Regards, Tim
signature.asc
Description: OpenPGP digital signature
- futimens() for WIN32/MinGW,
Tim Rühsen <=