[physfs] What to do if PHYSFS_close fails?
Ryan C. Gordon
icculus at icculus.org
Fri Jun 7 23:54:03 EDT 2013
> For the sake of comparison: fclose can also return an error code, but
> the file is always guaranteed to close.
Is that true? If it's built on top of Unix open(), then POSIX specifies
in the case of EIO or EINTR, your file descriptor is undefined at this
point (which is something worse than a leak...it may or may not be valid
to try close() again).
I guess my thought is you can check for failure, but you basically have
to just live with it or decide to abort. If it was a crucial file you
were writing, this would be a good place to warn the user.
It could be the disk failed while you were writing. It can happen.
That being said: PHYSFS_close() dictates that the PHYSFS_File* is still
valid in this case, but I would think the underlying OS handle isn't,
and it's not like you can will a failing disk to unfail and make the
PHYSFS_close() call work on a later try.
More information about the physfs