Only flush file handles on close if they were opened for writing.

This commit is contained in:
Ryan C. Gordon 2019-03-18 11:27:26 -04:00
parent e549fe0e0f
commit 5cbb460bcd
1 changed files with 8 additions and 5 deletions

View File

@ -2760,12 +2760,15 @@ static int closeHandleInOpenList(FileHandle **list, FileHandle *handle)
PHYSFS_uint8 *tmp = handle->buffer;
/* send our buffer to io... */
if (!PHYSFS_flush((PHYSFS_File *) handle))
return -1;
if (!handle->forReading)
{
if (!PHYSFS_flush((PHYSFS_File *) handle))
return -1;
/* ...then have io send it to the disk... */
else if (io->flush && !io->flush(io))
return -1;
/* ...then have io send it to the disk... */
else if (io->flush && !io->flush(io))
return -1;
} /* if */
/* ...then close the underlying file. */
io->destroy(io);