It appears using lseek() to seek to the end and back to determine file
size is inefficient in some cases (like with CIFS, see #7408).
Even Windows supports fstat() (well, almost, but we already have a
wrapper), so use that. It's unknown whether that will work better.
Although I like it more, because it doesn't mess with the file position.