git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] mingw: utime() handles NULL times parameter

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Jul 1, 2010, 11:07 UTC
Message-ID
<1277982466-29601-1-git-send-email-szeder@ira.uka.de>
In-Reply-To
<4C2C69AF.4010303@viscovery.net>
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>
---
On Thu, Jul 01, 2010 at 12:10:55PM +0200, Johannes Sixt wrote:
> 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.
 compat/mingw.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index 9a8e336..a54db74 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -304,8 +304,14 @@ 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->dwLowDateTime = mft->dwLowDateTime;
+		aft->dwHighDateTime = mft->dwHighDateTime;
+	}
 	if (!SetFileTime((HANDLE)_get_osfhandle(fh), NULL, &aft, &mft)) {
 		errno = EINVAL;
 		rc = -1;
-- 
1.7.2.rc0.54.g4d821
Previous: Johannes SixtNext: Johannes Sixt
Message 9 of 24 in “rerere: fix overeager gc”
  1. rerere: fix overeager gcSZEDER Gábor, Jun 29, 2010
  2. Junio C HamanoJun 29, 2010
  3. Johannes SixtJun 30, 2010
  4. SZEDER GáborJun 30, 2010
  5. Junio C HamanoJun 30, 2010
  6. Johannes SixtJun 30, 2010
  7. rerere: fix overeager gcSZEDER Gábor, Jul 1, 2010
  8. Johannes SixtJul 1, 2010
  9. 1/2 mingw: utime() handles NULL times parameterSZEDER Gábor, Jul 1, 2010
  10. 1/2 mingw_utime(): handle NULL times parameterJohannes Sixt, Jul 1, 2010
  11. 2/2 rerere: fix overeager gcSZEDER Gábor, Jul 1, 2010
  12. Junio C HamanoJul 1, 2010
  13. Johannes SixtJul 2, 2010
  14. Junio C HamanoJul 2, 2010
  15. Johannes SixtJul 5, 2010
  16. rerere: fix overeager gcSZEDER Gábor, Jul 8, 2010
  17. Junio C HamanoJul 9, 2010
  18. 1/2 mingw_utime(): handle NULL times parameterSZEDER Gábor, Jul 12, 2010
  19. 2/2 rerere: fix overeager gcSZEDER Gábor, Jul 12, 2010
  20. Junio C HamanoJul 13, 2010
  21. SZEDER GáborJul 14, 2010
  22. Junio C HamanoJul 14, 2010
  23. SZEDER GáborJul 14, 2010
  24. Johannes SixtJul 8, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.