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.
Is the stat header required on Windows? If not would it be possible to include this header conditional and remove the compat namespace?