From 78d47d3016a652a576e3ddf36f64c2f4fa1fd405 Mon Sep 17 00:00:00 2001 From: janwas Date: Mon, 2 Aug 2004 22:16:18 +0000 Subject: [PATCH] fixed funny bug: file write handles were cached; VFS writes (eg. screenshots) led to reload -> wiped out file contents temp solution: do not cache file writes; see latest build thread. This was SVN commit r885. --- source/lib/res/vfs.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/lib/res/vfs.cpp b/source/lib/res/vfs.cpp index a651d66cf6..de1a2cc9b2 100755 --- a/source/lib/res/vfs.cpp +++ b/source/lib/res/vfs.cpp @@ -1273,9 +1273,15 @@ static int VFile_reload(VFile* vf, const char* path, Handle) // open the file for synchronous or asynchronous IO. write access is // requested via FILE_WRITE flag, and is not possible for files in archives. -Handle vfs_open(const char* fn, uint flags /* = 0 */) +Handle vfs_open(const char* fn, uint file_flags /* = 0 */) { - Handle h = h_alloc(H_VFile, fn, 0, flags); + // do not cache handles for file writes + // (avoids h_reload reloading it, thereby wiping out the file contents) + uint res_flags = 0; + if(file_flags & FILE_WRITE) + res_flags = RES_TEMP; + + Handle h = h_alloc(H_VFile, fn, res_flags, file_flags); // pass file flags to init #ifdef PARANOIA