Windows utf8 utime fix.
authorJanne Hyvärinen <cse@sci.fi>
Sat, 20 Apr 2013 09:42:24 +0000 (12:42 +0300)
committerErik de Castro Lopo <erikd@mega-nerd.com>
Sun, 21 Apr 2013 07:56:16 +0000 (17:56 +1000)
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>
src/share/win_utf8_io/win_utf8_io.c

index d8736e1..26679c3 100644 (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 (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 = _wutime(wname, &ut);
+       ret = _wutime64(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;
-               }
-       }
-
        return ret;
 }