瀏覽代碼

Only flush file handles on close if they were opened for writing.
(transplanted from 89e1b79e10c6e9faf9e4c06dc357dee5ef2c7d4f)

Ryan C. Gordon 7 年之前
父節點
當前提交
fa34bb479d
共有 1 個文件被更改,包括 8 次插入5 次删除
  1. 8 5
      src/physfs.c

+ 8 - 5
src/physfs.c

@@ -2678,12 +2678,15 @@ static int closeHandleInOpenList(FileHandle **list, FileHandle *handle)
             PHYSFS_uint8 *tmp = handle->buffer;
             PHYSFS_uint8 *tmp = handle->buffer;
 
 
             /* send our buffer to io... */
             /* 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. */
             /* ...then close the underlying file. */
             io->destroy(io);
             io->destroy(io);