mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-04 22:00:19 -05:00
Restores the modification time of files in fixing.
This commit is contained in:
parent
e6b02b7d2d
commit
66e9c359fd
15 changed files with 226 additions and 67 deletions
39
mingw.c
39
mingw.c
|
|
@ -318,6 +318,45 @@ int windows_ftruncate(int fd, off64_t off)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int windows_futimes(int fd, struct timeval tv[2])
|
||||
{
|
||||
HANDLE h;
|
||||
FILETIME ft;
|
||||
uint64_t mtime;
|
||||
|
||||
if (fd == -1) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
h = (HANDLE)_get_osfhandle(fd);
|
||||
if (h == INVALID_HANDLE_VALUE) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert to windows time
|
||||
*
|
||||
* How To Convert a UNIX time_t to a Win32 FILETIME or SYSTEMTIME
|
||||
* http://support.microsoft.com/kb/167296
|
||||
*/
|
||||
mtime = tv[0].tv_sec;
|
||||
mtime *= 10000000;
|
||||
mtime += tv[0].tv_usec * 10;
|
||||
mtime += 116444736000000000;
|
||||
|
||||
ft.dwHighDateTime = mtime >> 32;
|
||||
ft.dwLowDateTime = mtime;
|
||||
|
||||
if (!SetFileTime(h, 0, 0, &ft)) {
|
||||
windows_errno(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int windows_rename(const char* a, const char* b)
|
||||
{
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue