Fix the build on Windows

Collateral damage: readdir_r isn't present in mingw, but bad old readdir
is fine for how we are using it.