use stat instead of lstat - mingw compatibility