Windows utf8 utime fix.

UTF-8 version of utime was completely broken and file timestamps were
not preserved.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
This commit is contained in:
Janne Hyvärinen 2013-04-20 12:42:24 +03:00 committed by Erik de Castro Lopo
parent 52fab8ba7e
commit e8ffe523f8

View File

@ -259,22 +259,20 @@ int chmod_utf8(const char *filename, int pmode)
int utime_utf8(const char *filename, struct utimbuf *times)
{
wchar_t *wname;
struct _utimbuf ut;
struct __utimbuf64 ut;
int ret;
if (!(wname = wchar_from_utf8(filename))) return -1;
ret = _wutime(wname, &ut);
free(wname);
if (ret != -1) {
if (sizeof(*times) == sizeof(ut)) {
memcpy(times, &ut, sizeof(ut));
} else {
times->actime = ut.actime;
times->modtime = ut.modtime;
}
if (sizeof(*times) == sizeof(ut)) {
memcpy(&ut, times, sizeof(ut));
} else {
ut.actime = times->actime;
ut.modtime = times->modtime;
}
if (!(wname = wchar_from_utf8(filename))) return -1;
ret = _wutime64(wname, &ut);
free(wname);
return ret;
}