From fa34bb479d05f3e6dcb7f746710164e9154c0b59 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 18 Mar 2019 11:27:26 -0400 Subject: [PATCH] Only flush file handles on close if they were opened for writing. (transplanted from 89e1b79e10c6e9faf9e4c06dc357dee5ef2c7d4f) --- src/physfs.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/physfs.c b/src/physfs.c index d0d5444f..fdb1405d 100644 --- a/src/physfs.c +++ b/src/physfs.c @@ -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);