Skip to content

Commit

Permalink
Only flush file handles on close if they were opened for writing.
Browse files Browse the repository at this point in the history
(transplanted from 89e1b79e10c6e9faf9e4c06dc357dee5ef2c7d4f)
  • Loading branch information
icculus committed Mar 18, 2019
1 parent 9a825fc commit fa34bb4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/physfs.c
Expand Up @@ -2678,12 +2678,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);
Expand Down

0 comments on commit fa34bb4

Please sign in to comment.