@matheusbsbs / matheus-bagliano / commits / ded2d47668
Fork 0

mingw_utime(): handle NULL times parameter

POSIX sayeth: "If times is a null pointer, the access and modification times of the file shall be set to the current time." Let's do so. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

SZEDER Gábor committed Jul 13, 2010 at 01:42 UTC ded2d47668c8e865465a7ad69665696f9b56f24b
1 file changed +7 -2
compat/mingw.c
+7 -2
@@ -304,8 +304,13 @@ int mingw_utime (const char *file_name, const struct utimbuf *times)
304 goto revert_attrs;
305 }
306
307 - time_t_to_filetime(times->modtime, &mft);
308 - time_t_to_filetime(times->actime, &aft);
307 + if (times) {
308 + time_t_to_filetime(times->modtime, &mft);
309 + time_t_to_filetime(times->actime, &aft);
310 + } else {
311 + GetSystemTimeAsFileTime(&mft);
312 + aft = mft;
313 + }
314 if (!SetFileTime((HANDLE)_get_osfhandle(fh), NULL, &aft, &mft)) {
315 errno = EINVAL;
316 rc = -1;