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

Re: Implementing stat() with FindFirstFile()

From
Johannes Sixt <j6t@kdbg.org>
Date
Mar 21, 2009, 19:55 UTC
Message-ID
<200903212055.15026.j6t@kdbg.org>
In-Reply-To
<20090321154738.GA27249@jeeves.jpl.local>
On Samstag, 21. März 2009, Magnus Bäck wrote:
> Is there any reason why compat/win32.h uses GetFileAttributesEx()
> instead of FindFirstFile() to implement the stat() call on Windows?
> The current implementation requires each queried file to be opened
> and closed while FindFirstFile() only reads the directory.

There is: File times are extremely important for git. Unfortunately, MS's implementation of stat and utime are broken, and they do use FindFirstFile(). Read up on the topic here:

http://search.cpan.org/~shay/Win32-UTCFileTime-1.50/lib/Win32/UTCFileTime.pm
To quote the important sentence:

"The problem with Microsoft's stat(2) and utime(2) [...] is basically this: file times reported by stat(2) or stored by utime(2) may change by an hour as we move into or out of daylight saving time (DST) if the computer is set to "Automatically adjust clock for daylight saving changes" [...]."

Be sure to read section "Background Reference".

Besides that, our stat() implementation is already ca. twice as fast as MSVCRT's stat(). (Thank you, Marius!)

-- Hannes
Previous: Magnus BäckNext: Magnus Bäck
Message 2 of 14 in “Implementing stat() with FindFirstFile()”
  1. Magnus BäckMar 21, 2009
  2. Johannes SixtMar 21, 2009
  3. Magnus BäckMar 24, 2009
  4. Johannes SixtMar 26, 2009
  5. Magnus BäckMar 26, 2009
  6. Johannes SchindelinMar 27, 2009
  7. Magnus BäckMar 29, 2009
  8. Johannes SchindelinMar 30, 2009
  9. Björn SteinbrinkMar 30, 2009
  10. Heiko VoigtMar 30, 2009
  11. Johannes SchindelinMar 30, 2009
  12. Magnus BäckMar 31, 2009
  13. Johannes SchindelinMar 31, 2009
  14. Nazri RamliyApr 1, 2009

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.