[PATCH 1/2 fixed] mingw_utime(): handle NULL times parameter
- From
Johannes Sixt <j.sixt@viscovery.net>
- Date
- Jul 1, 2010, 12:16 UTC
- Message-ID
- <4C2C8718.5080203@viscovery.net>
- In-Reply-To
- <1277982466-29601-1-git-send-email-szeder@ira.uka.de>
From: SZEDER Gábor <szeder@ira.uka.de>
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> --- >> Mental note: update mingw_utime to accept NULL for the second >> parameter... > > Here it is, but I don't have mingw, so it's completely untested.
Thanks. Here is a version that compiles; the interdiff is
@@ -309,8 +309,7 @@
time_t_to_filetime(times->actime, &aft);
} else {
GetSystemTimeAsFileTime(&mft);
- aft->dwLowDateTime = mft->dwLowDateTime;
- aft->dwHighDateTime = mft->dwHighDateTime;
+ aft = mft;
}
if (!SetFileTime((HANDLE)_get_osfhandle(fh), NULL, &aft, &mft)) {
errno = EINVAL;With this, the series passes the test suite on MinGW.
-- Hannes
compat/mingw.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c index 0722a6d..b6f0a7f 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -304,8 +304,13 @@ int mingw_utime (const char *file_name, const struct utimbuf *times) goto revert_attrs; } - time_t_to_filetime(times->modtime, &mft); - time_t_to_filetime(times->actime, &aft); + if (times) { + time_t_to_filetime(times->modtime, &mft); + time_t_to_filetime(times->actime, &aft); + } else { + GetSystemTimeAsFileTime(&mft); + aft = mft; + } if (!SetFileTime((HANDLE)_get_osfhandle(fh), NULL, &aft, &mft)) { errno = EINVAL; rc = -1;
-- 1.7.2.rc1.1057.g1270