From 5cbb460bcd14bd314e47666a133bcad2fc1332fd 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. --- src/physfs.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/physfs.c b/src/physfs.c index a16ad8c..eec40b2 100644 --- a/src/physfs.c +++ b/src/physfs.c @@ -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);