This is an optimization as it avoids an extra syscall, but it's also a workaround for fstat being not available on Windows.