Implementing stat() with FindFirstFile()
- From
- Magnus Bäck <baeck@swipnet.se>
- Date
- Mar 21, 2009, 15:47 UTC
- Message-ID
- <20090321154738.GA27249@jeeves.jpl.local>
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.
I made a couple of test programs that stat()ed the 176k files on my disk and got the following best times with GetFileAttributesEx() and FindFirstFile() respectively:
./getfattr.exe < filelist.txt 1.31s user 9.72s system 27% cpu 40.424 total ./findfirst.exe < filelist.txt 1.92s user 13.98s system 95% cpu 16.681 total
I searched the archive and found a couple of threads touching upon the subject, but nothing conclusive.
I have a (trivial) patch ready if such a change would be interesting.
-- Magnus Bäck baeck@swipnet.se