Don't use stat and lstat on Windows; lstat is missing, stat only provides
the modification times with second granularity (and does the wrong thing
regarding symlinks). Instead do a minimal reimplementation using the
native windows APIs.
This is an alternative to D98641. This one contains more compat churn
at the top of the file (reimplememtations of stat and lstat), but
requires much less modifications to the rest of the test. Therefore
I'd kind of prefer this one out of the two.