It turns out that GetFileInformationByHandle() succeeds even for pipes
and sockets. Hence, we fall back to Windows's own fstat() implementation
for everything except files. This also takes care of any error codes
(again, except for files - but we don't expect any errors here).