From e8ffe523f8b2703a27983d2717cb36f7ed02e7c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20Hyv=C3=A4rinen?= Date: Sat, 20 Apr 2013 12:42:24 +0300 Subject: [PATCH] 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 --- src/share/win_utf8_io/win_utf8_io.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/share/win_utf8_io/win_utf8_io.c b/src/share/win_utf8_io/win_utf8_io.c index d8736e16..26679c36 100644 --- a/src/share/win_utf8_io/win_utf8_io.c +++ b/src/share/win_utf8_io/win_utf8_io.c @@ -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; }