From e1265174571765b279434383788a52832b5992b4 Mon Sep 17 00:00:00 2001
From: Michael Wetherell <mike.wetherell@ntlworld.com>
Date: Sun, 13 Mar 2005 16:20:51 +0000
Subject: [PATCH] Add wxTempFileOutputStream

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32796 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/latex/wx/category.tex     |   1 +
 docs/latex/wx/classes.tex      |   1 +
 docs/latex/wx/tempfile.tex     |  22 ++++++-
 docs/latex/wx/tempfilestrm.tex |  55 +++++++++++++++++
 include/wx/file.h              |   7 +++
 include/wx/wfstream.h          |  25 ++++++++
 src/common/wfstream.cpp        |  27 +++++++++
 tests/Makefile.in              |   4 ++
 tests/makefile.bcc             |  36 ++++++++---
 tests/makefile.gcc             |  36 +++++++----
 tests/makefile.vc              |  54 +++++++++++------
 tests/makefile.wat             |  53 +++++++++-------
 tests/streams/bstream.cpp      |   1 +
 tests/streams/tempfile.cpp     | 107 +++++++++++++++++++++++++++++++++
 tests/test.bkl                 |   1 +
 tests/test_test.dsp            |   4 ++
 16 files changed, 370 insertions(+), 64 deletions(-)
 create mode 100644 docs/latex/wx/tempfilestrm.tex
 create mode 100644 tests/streams/tempfile.cpp

diff --git a/docs/latex/wx/category.tex b/docs/latex/wx/category.tex
index 0160e81446..367f939a6f 100644
--- a/docs/latex/wx/category.tex
+++ b/docs/latex/wx/category.tex
@@ -493,6 +493,7 @@ libraries, and to provide enhanced functionality.
 \twocolitem{\helpref{wxFileOutputStream}{wxfileoutputstream}}{File output stream class}
 \twocolitem{\helpref{wxFFileInputStream}{wxffileinputstream}}{Another file input stream class}
 \twocolitem{\helpref{wxFFileOutputStream}{wxffileoutputstream}}{Another file output stream class}
+\twocolitem{\helpref{wxTempFileOutputStream}{wxtempfileoutputstream}}{Stream to safely replace an existing file}
 \twocolitem{\helpref{wxStringInputStream}{wxstringinputstream}}{String input stream class}
 \twocolitem{\helpref{wxStringOutputStream}{wxstringoutputstream}}{String output stream class}
 \twocolitem{\helpref{wxZlibInputStream}{wxzlibinputstream}}{Zlib (compression) input stream class}
diff --git a/docs/latex/wx/classes.tex b/docs/latex/wx/classes.tex
index 4987765079..10b9d36ec9 100644
--- a/docs/latex/wx/classes.tex
+++ b/docs/latex/wx/classes.tex
@@ -323,6 +323,7 @@
 \input tcpconn.tex
 \input tcpservr.tex
 \input tempfile.tex
+\input tempfilestrm.tex
 \input text.tex
 \input txtdatob.tex
 \input txtdrptg.tex
diff --git a/docs/latex/wx/tempfile.tex b/docs/latex/wx/tempfile.tex
index 06a03a0d1e..e7c0c98f68 100644
--- a/docs/latex/wx/tempfile.tex
+++ b/docs/latex/wx/tempfile.tex
@@ -43,7 +43,8 @@ No base class
 
 \wxheading{See also:}
 
-\helpref{wxFile}{wxfile}
+\helpref{wxFile}{wxfile}\\
+\helpref{wxTempFileOutputStream}{wxtempfileoutputstream}
 
 \latexignore{\rtfignore{\wxheading{Members}}}
 
@@ -79,6 +80,25 @@ and the program should have write access to it for the function to succeed.
 
 Returns {\tt true} if the file was successfully opened.
 
+\membersection{wxTempFile::Length}\label{wxtempfilelength}
+
+\constfunc{wxFileOffset}{Length}{\void}
+
+Returns the length of the file.
+
+\membersection{wxTempFile::Seek}\label{wxtempfileseek}
+
+\func{wxFileOffset}{Seek}{\param{wxFileOffset }{ofs}, \param{wxSeekMode }{mode = wxFromStart}}
+
+Seeks to the specified position.
+
+\membersection{wxTempFile::Tell}\label{wxtempfiletell}
+
+\constfunc{wxFileOffset}{Tell}{\void}
+
+Returns the current position or wxInvalidOffset if file is not opened or if another
+error occurred.
+
 \membersection{wxTempFile::Write}\label{wxtempfilewrite}
 
 \func{bool}{Write}{\param{const void }{*p}, \param{size\_t }{n}}
diff --git a/docs/latex/wx/tempfilestrm.tex b/docs/latex/wx/tempfilestrm.tex
new file mode 100644
index 0000000000..01fe8964a0
--- /dev/null
+++ b/docs/latex/wx/tempfilestrm.tex
@@ -0,0 +1,55 @@
+%
+% automatically generated by HelpGen $Revision$ from
+% wx/wfstream.h at 07/Mar/05 20:45:33
+%
+
+\section{\class{wxTempFileOutputStream}}\label{wxtempfileoutputstream}
+
+wxTempFileOutputStream is an output stream based on \helpref{wxTempFile}{wxtempfile}. It
+provides a relatively safe way to replace the contents of the
+existing file.
+
+\wxheading{Derived from}
+
+\helpref{wxOutputStream}{wxoutputstream}
+
+\wxheading{Include files}
+
+<wx/wfstream.h>
+
+\wxheading{See also}
+
+\helpref{wxTempFile}{wxtempfile}
+
+\latexignore{\rtfignore{\wxheading{Members}}}
+
+
+\membersection{wxTempFileOutputStream::wxTempFileOutputStream}\label{wxtempfileoutputstreamwxtempfileoutputstream}
+
+\func{}{wxTempFileOutputStream}{\param{const wxString\& }{fileName}}
+
+Associates wxTempFileOutputStream with the file to be replaced and opens it. You should use 
+\helpref{IsOk}{wxstreambaseisok} to verify if the constructor succeeded.
+
+Call \helpref{Commit()}{wxtempfileoutputstreamcommit} or \helpref{Close()}{wxoutputstreamclose} to
+replace the old file and close this one. Calling \helpref{Discard()}{wxtempfileoutputstreamdiscard} 
+(or allowing the destructor to do it) will discard the changes.
+
+
+\membersection{wxTempFileOutputStream::Commit}\label{wxtempfileoutputstreamcommit}
+
+\func{bool}{Commit}{\void}
+
+Validate changes: deletes the old file of the given name and renames the new
+file to the old name. Returns {\tt true} if both actions succeeded. If {\tt false} is
+returned it may unfortunately mean two quite different things: either that
+either the old file couldn't be deleted or that the new file couldn't be renamed
+to the old name.
+
+
+\membersection{wxTempFileOutputStream::Discard}\label{wxtempfileoutputstreamdiscard}
+
+\func{void}{Discard}{\void}
+
+Discard changes: the old file contents are not changed, the temporary file is
+deleted.
diff --git a/include/wx/file.h b/include/wx/file.h
index 3382610c57..abb427af66 100644
--- a/include/wx/file.h
+++ b/include/wx/file.h
@@ -164,6 +164,13 @@ public:
 
   // is the file opened?
   bool IsOpened() const { return m_file.IsOpened(); }
+    // get current file length
+  wxFileOffset Length() const { return m_file.Length(); }
+    // move ptr ofs bytes related to start/current offset/end of file
+  wxFileOffset Seek(wxFileOffset ofs, wxSeekMode mode = wxFromStart)
+    { return m_file.Seek(ofs, mode); }
+    // get current offset
+  wxFileOffset Tell() const { return m_file.Tell(); }
 
   // I/O (both functions return true on success, false on failure)
   bool Write(const void *p, size_t n) { return m_file.Write(p, n) == n; }
diff --git a/include/wx/wfstream.h b/include/wx/wfstream.h
index d0d50a608c..79cdb866cf 100644
--- a/include/wx/wfstream.h
+++ b/include/wx/wfstream.h
@@ -88,6 +88,31 @@ protected:
     DECLARE_NO_COPY_CLASS(wxFileOutputStream)
 };
 
+class WXDLLIMPEXP_BASE wxTempFileOutputStream : public wxOutputStream
+{
+public:
+    wxTempFileOutputStream(const wxString& fileName);
+    virtual ~wxTempFileOutputStream();
+
+    bool Close() { return Commit(); }
+    virtual bool Commit() { return m_file->Commit(); }
+    virtual void Discard() { m_file->Discard(); }
+
+    wxFileOffset GetLength() const { return m_file->Length(); }
+    bool IsSeekable() const { return true; }
+
+protected:
+    size_t OnSysWrite(const void *buffer, size_t size);
+    wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode)
+        { return m_file->Seek(pos, mode); }
+    wxFileOffset OnSysTell() const { return m_file->Tell(); }
+
+private:
+    wxTempFile *m_file;
+
+    DECLARE_NO_COPY_CLASS(wxTempFileOutputStream)
+};
+
 class WXDLLIMPEXP_BASE wxFileStream : public wxFileInputStream,
                                       public wxFileOutputStream
 {
diff --git a/src/common/wfstream.cpp b/src/common/wfstream.cpp
index 8370eebc6f..9d15b4f9b6 100644
--- a/src/common/wfstream.cpp
+++ b/src/common/wfstream.cpp
@@ -183,6 +183,33 @@ wxFileOffset wxFileOutputStream::GetLength() const
     return m_file->Length();
 }
 
+// ----------------------------------------------------------------------------
+// wxTempFileOutputStream
+// ----------------------------------------------------------------------------
+
+wxTempFileOutputStream::wxTempFileOutputStream(const wxString& fileName)
+{
+    m_file = new wxTempFile(fileName);
+
+    if (!m_file->IsOpened())
+        m_lasterror = wxSTREAM_WRITE_ERROR;
+}
+
+wxTempFileOutputStream::~wxTempFileOutputStream()
+{
+    if (m_file->IsOpened())
+        Discard();
+    delete m_file;
+}
+
+size_t wxTempFileOutputStream::OnSysWrite(const void *buffer, size_t size)
+{
+    if (IsOk() && m_file->Write(buffer, size))
+        return size;
+    m_lasterror = wxSTREAM_WRITE_ERROR;
+    return 0;
+}
+
 // ----------------------------------------------------------------------------
 // wxFileStream
 // ----------------------------------------------------------------------------
diff --git a/tests/Makefile.in b/tests/Makefile.in
index b53355ed4d..06ca3197f1 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -71,6 +71,7 @@ TEST_OBJECTS =  \
 	test_largefile.o \
 	test_memstream.o \
 	test_sstream.o \
+	test_tempfile.o \
 	test_textstreamtest.o \
 	test_zlibstream.o \
 	test_uris.o
@@ -321,6 +322,9 @@ test_memstream.o: $(srcdir)/streams/memstream.cpp $(TEST_ODEP)
 test_sstream.o: $(srcdir)/streams/sstream.cpp $(TEST_ODEP)
 	$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/streams/sstream.cpp
 
+test_tempfile.o: $(srcdir)/streams/tempfile.cpp $(TEST_ODEP)
+	$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/streams/tempfile.cpp
+
 test_textstreamtest.o: $(srcdir)/streams/textstreamtest.cpp $(TEST_ODEP)
 	$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/streams/textstreamtest.cpp
 
diff --git a/tests/makefile.bcc b/tests/makefile.bcc
index ab60059c57..6ed5c2423d 100644
--- a/tests/makefile.bcc
+++ b/tests/makefile.bcc
@@ -1,6 +1,6 @@
 # =========================================================================
 #     This makefile was generated by
-#     Bakefile 0.1.6 (http://bakefile.sourceforge.net)
+#     Bakefile 0.1.7 (http://bakefile.sourceforge.net)
 #     Do not modify, all changes will be overwritten!
 # =========================================================================
 
@@ -28,10 +28,10 @@ LIBDIRNAME = .\..\lib\bcc_$(LIBTYPE_SUFFIX)$(CFG)
 SETUPHDIR = \
 	$(LIBDIRNAME)\$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)
 TEST_CXXFLAGS = $(__RUNTIME_LIBS) -I$(BCCDIR)\include $(__DEBUGINFO) \
-	$(__OPTIMIZEFLAG) -tWM -D__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) \
-	$(__UNICODE_DEFINE_p) -I.\..\include -I$(SETUPHDIR) -I. $(__DLLFLAG_p) \
-	-DwxUSE_GUI=0 $(CPPUNIT_CFLAGS) -Hu -H=$(OBJS)\testprec_test.csm $(CPPFLAGS) \
-	$(CXXFLAGS)
+	$(__OPTIMIZEFLAG) $(__THREADSFLAG_0) -D__WXMSW__ $(__WXUNIV_DEFINE_p) \
+	$(__DEBUG_DEFINE_p) $(__UNICODE_DEFINE_p) -I.\..\include -I$(SETUPHDIR) -I. \
+	$(__DLLFLAG_p) -DwxUSE_GUI=0 $(CPPUNIT_CFLAGS) -Hu \
+	-H=$(OBJS)\testprec_test.csm $(CPPFLAGS) $(CXXFLAGS)
 TEST_OBJECTS =  \
 	$(OBJS)\test_dummy.obj \
 	$(OBJS)\test_test.obj \
@@ -62,13 +62,14 @@ TEST_OBJECTS =  \
 	$(OBJS)\test_largefile.obj \
 	$(OBJS)\test_memstream.obj \
 	$(OBJS)\test_sstream.obj \
+	$(OBJS)\test_tempfile.obj \
 	$(OBJS)\test_textstreamtest.obj \
 	$(OBJS)\test_zlibstream.obj \
 	$(OBJS)\test_uris.obj
 TEST_GUI_CXXFLAGS = $(__RUNTIME_LIBS) -I$(BCCDIR)\include $(__DEBUGINFO) \
-	$(__OPTIMIZEFLAG) -tWM -D__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) \
-	$(__UNICODE_DEFINE_p) -I.\..\include -I$(SETUPHDIR) -I. $(__DLLFLAG_p) \
-	-I.\..\samples -DNOPCH $(CPPUNIT_CFLAGS) -Hu \
+	$(__OPTIMIZEFLAG) $(__THREADSFLAG_0) -D__WXMSW__ $(__WXUNIV_DEFINE_p) \
+	$(__DEBUG_DEFINE_p) $(__UNICODE_DEFINE_p) -I.\..\include -I$(SETUPHDIR) -I. \
+	$(__DLLFLAG_p) -I.\..\samples -DNOPCH $(CPPUNIT_CFLAGS) -Hu \
 	-H=$(OBJS)\testprec_test_gui.csm $(CPPFLAGS) $(CXXFLAGS)
 TEST_GUI_OBJECTS =  \
 	$(OBJS)\test_gui_dummy.obj \
@@ -144,6 +145,18 @@ __OPTIMIZEFLAG = -Od
 !if "$(BUILD)" == "release"
 __OPTIMIZEFLAG = -O2
 !endif
+!if "$(USE_THREADS)" == "0"
+__THREADSFLAG = 
+!endif
+!if "$(USE_THREADS)" == "1"
+__THREADSFLAG = mt
+!endif
+!if "$(USE_THREADS)" == "0"
+__THREADSFLAG_0 = 
+!endif
+!if "$(USE_THREADS)" == "1"
+__THREADSFLAG_0 = -tWM
+!endif
 !if "$(RUNTIME_LIBS)" == "dynamic"
 __RUNTIME_LIBS = -tWR
 !endif
@@ -232,13 +245,13 @@ clean:
 
 $(OBJS)\test.exe: $(OBJS)\test_dummy.obj  $(TEST_OBJECTS)
 	ilink32 -Tpe -q $(LDFLAGS) -L$(BCCDIR)\lib -L$(BCCDIR)\lib\psdk $(__DEBUGINFO)  -L$(LIBDIRNAME) -ap $(CPPUNIT_LIBS) @&&|
-	c0x32.obj $(TEST_OBJECTS),$@,, $(__WXLIB_NET_p)  $(__WXLIB_BASE_p)  $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) wxzlib$(WXDEBUGFLAG).lib  wxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__UNICOWS_LIB_p) ole2w32.lib oleacc.lib odbc32.lib import32.lib cw32mt$(__RUNTIME_LIBS_0).lib,,
+	c0x32.obj $(TEST_OBJECTS),$@,, $(__WXLIB_NET_p)  $(__WXLIB_BASE_p)  $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) wxzlib$(WXDEBUGFLAG).lib  wxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__UNICOWS_LIB_p) ole2w32.lib oleacc.lib odbc32.lib import32.lib cw32$(__THREADSFLAG)$(__RUNTIME_LIBS_0).lib,,
 |
 
 !if "$(USE_GUI)" == "1"
 $(OBJS)\test_gui.exe: $(OBJS)\test_gui_dummy.obj  $(TEST_GUI_OBJECTS)  $(OBJS)\test_gui_sample.res
 	ilink32 -Tpe -q $(LDFLAGS) -L$(BCCDIR)\lib -L$(BCCDIR)\lib\psdk $(__DEBUGINFO)  -L$(LIBDIRNAME) $(CPPUNIT_LIBS) -ap @&&|
-	c0x32.obj $(TEST_GUI_OBJECTS),$@,, $(__WXLIB_CORE_p)  $(__WXLIB_BASE_p)  $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) wxzlib$(WXDEBUGFLAG).lib  wxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__UNICOWS_LIB_p) ole2w32.lib oleacc.lib odbc32.lib  import32.lib cw32mt$(__RUNTIME_LIBS_0).lib,, $(OBJS)\test_gui_sample.res
+	c0x32.obj $(TEST_GUI_OBJECTS),$@,, $(__WXLIB_CORE_p)  $(__WXLIB_BASE_p)  $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) wxzlib$(WXDEBUGFLAG).lib  wxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__UNICOWS_LIB_p) ole2w32.lib oleacc.lib odbc32.lib  import32.lib cw32$(__THREADSFLAG)$(__RUNTIME_LIBS_0).lib,, $(OBJS)\test_gui_sample.res
 |
 !endif
 
@@ -333,6 +346,9 @@ $(OBJS)\test_memstream.obj: .\streams\memstream.cpp
 $(OBJS)\test_sstream.obj: .\streams\sstream.cpp
 	$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
 
+$(OBJS)\test_tempfile.obj: .\streams\tempfile.cpp
+	$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
+
 $(OBJS)\test_textstreamtest.obj: .\streams\textstreamtest.cpp
 	$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**
 
diff --git a/tests/makefile.gcc b/tests/makefile.gcc
index 0ade361a4a..e03845161f 100644
--- a/tests/makefile.gcc
+++ b/tests/makefile.gcc
@@ -1,6 +1,6 @@
 # =========================================================================
 #     This makefile was generated by
-#     Bakefile 0.1.6 (http://bakefile.sourceforge.net)
+#     Bakefile 0.1.7 (http://bakefile.sourceforge.net)
 #     Do not modify, all changes will be overwritten!
 # =========================================================================
 
@@ -21,8 +21,8 @@ SETUPHDIR = \
 TEST_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(GCCFLAGS) -DHAVE_W32API_H \
 	-D__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__UNICODE_DEFINE_p) \
 	-I.\..\include -I$(SETUPHDIR) -W -Wall -I. $(__DLLFLAG_p) -DwxUSE_GUI=0 \
-	$(CPPUNIT_CFLAGS) $(__EXCEPTIONSFLAG) $(__EXCEPTIONSFLAG_0) \
-	-Wno-ctor-dtor-privacy $(CPPFLAGS) $(CXXFLAGS)
+	$(CPPUNIT_CFLAGS) $(__RTTIFLAG) $(__EXCEPTIONSFLAG) -Wno-ctor-dtor-privacy \
+	$(CPPFLAGS) $(CXXFLAGS)
 TEST_OBJECTS =  \
 	$(OBJS)\test_dummy.o \
 	$(OBJS)\test_test.o \
@@ -53,14 +53,15 @@ TEST_OBJECTS =  \
 	$(OBJS)\test_largefile.o \
 	$(OBJS)\test_memstream.o \
 	$(OBJS)\test_sstream.o \
+	$(OBJS)\test_tempfile.o \
 	$(OBJS)\test_textstreamtest.o \
 	$(OBJS)\test_zlibstream.o \
 	$(OBJS)\test_uris.o
 TEST_GUI_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(GCCFLAGS) \
 	-DHAVE_W32API_H -D__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) \
 	$(__UNICODE_DEFINE_p) -I.\..\include -I$(SETUPHDIR) -W -Wall -I. \
-	$(__DLLFLAG_p) -I.\..\samples -DNOPCH $(CPPUNIT_CFLAGS) $(__EXCEPTIONSFLAG) \
-	$(__EXCEPTIONSFLAG_0) -Wno-ctor-dtor-privacy $(CPPFLAGS) $(CXXFLAGS)
+	$(__DLLFLAG_p) -I.\..\samples -DNOPCH $(CPPUNIT_CFLAGS) $(__RTTIFLAG) \
+	$(__EXCEPTIONSFLAG) -Wno-ctor-dtor-privacy $(CPPFLAGS) $(CXXFLAGS)
 TEST_GUI_OBJECTS =  \
 	$(OBJS)\test_gui_sample_rc.o \
 	$(OBJS)\test_gui_dummy.o \
@@ -143,17 +144,23 @@ endif
 ifeq ($(BUILD),release)
 __OPTIMIZEFLAG = -O2
 endif
-ifeq ($(USE_EXCEPTIONS),0)
-__EXCEPTIONSFLAG = -fno-rtti
+ifeq ($(USE_THREADS),0)
+__THREADSFLAG = 
 endif
-ifeq ($(USE_EXCEPTIONS),1)
-__EXCEPTIONSFLAG = 
+ifeq ($(USE_THREADS),1)
+__THREADSFLAG = -mthreads
+endif
+ifeq ($(USE_RTTI),0)
+__RTTIFLAG = -fno-rtti
+endif
+ifeq ($(USE_RTTI),1)
+__RTTIFLAG = 
 endif
 ifeq ($(USE_EXCEPTIONS),0)
-__EXCEPTIONSFLAG_0 = -fno-exceptions
+__EXCEPTIONSFLAG = -fno-exceptions
 endif
 ifeq ($(USE_EXCEPTIONS),1)
-__EXCEPTIONSFLAG_0 = 
+__EXCEPTIONSFLAG = 
 endif
 ifeq ($(WXUNIV),1)
 __WXUNIV_DEFINE_p = -D__WXUNIVERSAL__
@@ -224,11 +231,11 @@ clean:
 	-if exist $(OBJS)\test_gui.exe del $(OBJS)\test_gui.exe
 
 $(OBJS)\test.exe: $(TEST_OBJECTS)
-	$(CXX) -o $@ $(TEST_OBJECTS) $(LDFLAGS) $(__DEBUGINFO) -mthreads -L$(LIBDIRNAME)  $(CPPUNIT_LIBS)  $(__WXLIB_NET_p)  $(__WXLIB_BASE_p)  $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) -lwxzlib$(WXDEBUGFLAG)  -lwxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG) -lwxexpat$(WXDEBUGFLAG) $(EXTRALIBS_FOR_BASE) $(__UNICOWS_LIB_p) -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lodbc32
+	$(CXX) -o $@ $(TEST_OBJECTS) $(LDFLAGS) $(__DEBUGINFO) $(__THREADSFLAG) -L$(LIBDIRNAME)  $(CPPUNIT_LIBS)  $(__WXLIB_NET_p)  $(__WXLIB_BASE_p)  $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) -lwxzlib$(WXDEBUGFLAG)  -lwxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG) -lwxexpat$(WXDEBUGFLAG) $(EXTRALIBS_FOR_BASE) $(__UNICOWS_LIB_p) -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lodbc32
 
 ifeq ($(USE_GUI),1)
 $(OBJS)\test_gui.exe: $(TEST_GUI_OBJECTS) $(OBJS)\test_gui_sample_rc.o
-	$(CXX) -o $@ $(TEST_GUI_OBJECTS) $(LDFLAGS) $(__DEBUGINFO) -mthreads -L$(LIBDIRNAME) $(CPPUNIT_LIBS)   $(__WXLIB_CORE_p)  $(__WXLIB_BASE_p)  $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) -lwxzlib$(WXDEBUGFLAG)  -lwxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG) -lwxexpat$(WXDEBUGFLAG) $(EXTRALIBS_FOR_BASE) $(__UNICOWS_LIB_p) -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lodbc32
+	$(CXX) -o $@ $(TEST_GUI_OBJECTS) $(LDFLAGS) $(__DEBUGINFO) $(__THREADSFLAG) -L$(LIBDIRNAME) $(CPPUNIT_LIBS)   $(__WXLIB_CORE_p)  $(__WXLIB_BASE_p)  $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) -lwxzlib$(WXDEBUGFLAG)  -lwxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG) -lwxexpat$(WXDEBUGFLAG) $(EXTRALIBS_FOR_BASE) $(__UNICOWS_LIB_p) -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lodbc32
 endif
 
 data: 
@@ -322,6 +329,9 @@ $(OBJS)\test_memstream.o: ./streams/memstream.cpp
 $(OBJS)\test_sstream.o: ./streams/sstream.cpp
 	$(CXX) -c -o $@ $(TEST_CXXFLAGS) $<
 
+$(OBJS)\test_tempfile.o: ./streams/tempfile.cpp
+	$(CXX) -c -o $@ $(TEST_CXXFLAGS) $<
+
 $(OBJS)\test_textstreamtest.o: ./streams/textstreamtest.cpp
 	$(CXX) -c -o $@ $(TEST_CXXFLAGS) $<
 
diff --git a/tests/makefile.vc b/tests/makefile.vc
index 10d9f2fda2..cbb4b7b9b8 100644
--- a/tests/makefile.vc
+++ b/tests/makefile.vc
@@ -1,6 +1,6 @@
 # =========================================================================
 #     This makefile was generated by
-#     Bakefile 0.1.6 (http://bakefile.sourceforge.net)
+#     Bakefile 0.1.7 (http://bakefile.sourceforge.net)
 #     Do not modify, all changes will be overwritten!
 # =========================================================================
 
@@ -18,12 +18,12 @@ OBJS = \
 LIBDIRNAME = .\..\lib\vc_$(LIBTYPE_SUFFIX)$(CFG)
 SETUPHDIR = \
 	$(LIBDIRNAME)\$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)
-TEST_CXXFLAGS = /M$(__RUNTIME_LIBS)$(__DEBUGRUNTIME_3) /DWIN32 $(__DEBUGINFO) \
-	/Fd$(OBJS)\test.pdb $(____DEBUGRUNTIME_2_p) $(__OPTIMIZEFLAG) \
-	$(__NO_VC_CRTDBG_p) /D__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) \
-	$(__UNICODE_DEFINE_p) /I.\..\include /I$(SETUPHDIR) /W4 /I. $(__DLLFLAG_p) \
-	/D_CONSOLE /DwxUSE_GUI=0 $(CPPUNIT_CFLAGS) $(__EXCEPTIONSFLAG) \
-	$(__EXCEPTIONSFLAG_0) /Yu"testprec.h" /Fp"$(OBJS)\testprec_test.pch" \
+TEST_CXXFLAGS = /M$(__RUNTIME_LIBS_7)$(__DEBUGRUNTIME_3) /DWIN32 \
+	$(__DEBUGINFO) /Fd$(OBJS)\test.pdb $(____DEBUGRUNTIME_2_p) \
+	$(__OPTIMIZEFLAG) $(__NO_VC_CRTDBG_p) /D__WXMSW__ $(__WXUNIV_DEFINE_p) \
+	$(__DEBUG_DEFINE_p) $(__UNICODE_DEFINE_p) /I.\..\include /I$(SETUPHDIR) /W4 \
+	/I. $(__DLLFLAG_p) /D_CONSOLE /DwxUSE_GUI=0 $(CPPUNIT_CFLAGS) $(__RTTIFLAG) \
+	$(__EXCEPTIONSFLAG) /Yu"testprec.h" /Fp"$(OBJS)\testprec_test.pch" \
 	$(CPPFLAGS) $(CXXFLAGS)
 TEST_OBJECTS =  \
 	$(OBJS)\test_dummy.obj \
@@ -55,15 +55,16 @@ TEST_OBJECTS =  \
 	$(OBJS)\test_largefile.obj \
 	$(OBJS)\test_memstream.obj \
 	$(OBJS)\test_sstream.obj \
+	$(OBJS)\test_tempfile.obj \
 	$(OBJS)\test_textstreamtest.obj \
 	$(OBJS)\test_zlibstream.obj \
 	$(OBJS)\test_uris.obj
-TEST_GUI_CXXFLAGS = /M$(__RUNTIME_LIBS)$(__DEBUGRUNTIME_17) /DWIN32 \
+TEST_GUI_CXXFLAGS = /M$(__RUNTIME_LIBS_21)$(__DEBUGRUNTIME_17) /DWIN32 \
 	$(__DEBUGINFO) /Fd$(OBJS)\test_gui.pdb $(____DEBUGRUNTIME_16_p) \
 	$(__OPTIMIZEFLAG) $(__NO_VC_CRTDBG_p) /D__WXMSW__ $(__WXUNIV_DEFINE_p) \
 	$(__DEBUG_DEFINE_p) $(__UNICODE_DEFINE_p) /I.\..\include /I$(SETUPHDIR) /W4 \
 	/I. $(__DLLFLAG_p) /I.\..\samples /DNOPCH $(CPPUNIT_CFLAGS) /D_CONSOLE \
-	$(__EXCEPTIONSFLAG) $(__EXCEPTIONSFLAG_0) /Yu"testprec.h" \
+	$(__RTTIFLAG) $(__EXCEPTIONSFLAG) /Yu"testprec.h" \
 	/Fp"$(OBJS)\testprec_test_gui.pch" $(CPPFLAGS) $(CXXFLAGS)
 TEST_GUI_OBJECTS =  \
 	$(OBJS)\test_gui_sample.res \
@@ -126,6 +127,12 @@ __DEBUGRUNTIME_3 = d
 !if "$(DEBUG_RUNTIME_LIBS)" == "default"
 __DEBUGRUNTIME_3 = $(__DEBUGINFO_2)
 !endif
+!if "$(RUNTIME_LIBS)" == "dynamic"
+__RUNTIME_LIBS_7 = D
+!endif
+!if "$(RUNTIME_LIBS)" == "static"
+__RUNTIME_LIBS_7 = $(__THREADSFLAG)
+!endif
 !if "$(MONOLITHIC)" == "0"
 __WXLIB_NET_p = \
 	wxbase$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_net.lib
@@ -172,6 +179,12 @@ __DEBUGRUNTIME_17 = d
 !if "$(DEBUG_RUNTIME_LIBS)" == "default"
 __DEBUGRUNTIME_17 = $(__DEBUGINFO_2)
 !endif
+!if "$(RUNTIME_LIBS)" == "dynamic"
+__RUNTIME_LIBS_21 = D
+!endif
+!if "$(RUNTIME_LIBS)" == "static"
+__RUNTIME_LIBS_21 = $(__THREADSFLAG)
+!endif
 !if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "0"
 __NO_VC_CRTDBG_p_3 = /d __NO_VC_CRTDBG__
 !endif
@@ -251,23 +264,23 @@ __OPTIMIZEFLAG = /Od
 !if "$(BUILD)" == "release"
 __OPTIMIZEFLAG = /O2
 !endif
-!if "$(RUNTIME_LIBS)" == "dynamic"
-__RUNTIME_LIBS = D
+!if "$(USE_THREADS)" == "0"
+__THREADSFLAG = L
 !endif
-!if "$(RUNTIME_LIBS)" == "static"
-__RUNTIME_LIBS = T
+!if "$(USE_THREADS)" == "1"
+__THREADSFLAG = T
 !endif
-!if "$(USE_EXCEPTIONS)" == "0"
-__EXCEPTIONSFLAG = 
+!if "$(USE_RTTI)" == "0"
+__RTTIFLAG = 
 !endif
-!if "$(USE_EXCEPTIONS)" == "1"
-__EXCEPTIONSFLAG = /GR
+!if "$(USE_RTTI)" == "1"
+__RTTIFLAG = /GR
 !endif
 !if "$(USE_EXCEPTIONS)" == "0"
-__EXCEPTIONSFLAG_0 = 
+__EXCEPTIONSFLAG = 
 !endif
 !if "$(USE_EXCEPTIONS)" == "1"
-__EXCEPTIONSFLAG_0 = /GX
+__EXCEPTIONSFLAG = /GX
 !endif
 !if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "0"
 __NO_VC_CRTDBG_p = /D__NO_VC_CRTDBG__
@@ -434,6 +447,9 @@ $(OBJS)\test_memstream.obj: .\streams\memstream.cpp
 $(OBJS)\test_sstream.obj: .\streams\sstream.cpp
 	$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
 
+$(OBJS)\test_tempfile.obj: .\streams\tempfile.cpp
+	$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
+
 $(OBJS)\test_textstreamtest.obj: .\streams\textstreamtest.cpp
 	$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**
 
diff --git a/tests/makefile.wat b/tests/makefile.wat
index 2b5866d43c..ac72d15dd4 100644
--- a/tests/makefile.wat
+++ b/tests/makefile.wat
@@ -1,6 +1,6 @@
 # =========================================================================
 #     This makefile was generated by
-#     Bakefile 0.1.6 (http://bakefile.sourceforge.net)
+#     Bakefile 0.1.7 (http://bakefile.sourceforge.net)
 #     Do not modify, all changes will be overwritten!
 # =========================================================================
 
@@ -124,6 +124,13 @@ __OPTIMIZEFLAG = -od
 !ifeq BUILD release
 __OPTIMIZEFLAG = -ot -ox
 !endif
+__THREADSFLAG =
+!ifeq USE_THREADS 0
+__THREADSFLAG = 
+!endif
+!ifeq USE_THREADS 1
+__THREADSFLAG = -bm
+!endif
 __RUNTIME_LIBS =
 !ifeq RUNTIME_LIBS dynamic
 __RUNTIME_LIBS = -br
@@ -131,19 +138,19 @@ __RUNTIME_LIBS = -br
 !ifeq RUNTIME_LIBS static
 __RUNTIME_LIBS = 
 !endif
-__EXCEPTIONSFLAG =
-!ifeq USE_EXCEPTIONS 0
-__EXCEPTIONSFLAG = 
+__RTTIFLAG =
+!ifeq USE_RTTI 0
+__RTTIFLAG = 
 !endif
-!ifeq USE_EXCEPTIONS 1
-__EXCEPTIONSFLAG = -xr
+!ifeq USE_RTTI 1
+__RTTIFLAG = -xr
 !endif
-__EXCEPTIONSFLAG_0 =
+__EXCEPTIONSFLAG =
 !ifeq USE_EXCEPTIONS 0
-__EXCEPTIONSFLAG_0 = 
+__EXCEPTIONSFLAG = 
 !endif
 !ifeq USE_EXCEPTIONS 1
-__EXCEPTIONSFLAG_0 = -xs
+__EXCEPTIONSFLAG = -xs
 !endif
 __WXLIB_BASE_p =
 !ifeq MONOLITHIC 0
@@ -197,12 +204,12 @@ OBJS = &
 LIBDIRNAME = .\..\lib\wat_$(LIBTYPE_SUFFIX)$(CFG)
 SETUPHDIR = &
 	$(LIBDIRNAME)\$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)
-TEST_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) -bm $(__RUNTIME_LIBS) &
-	-d__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__UNICODE_DEFINE_p) &
-	-i=.\..\include -i=$(SETUPHDIR) -wx -wcd=549 -wcd=656 -wcd=657 -wcd=667 -i=. &
-	$(__DLLFLAG_p) -dwxUSE_GUI=0 $(CPPUNIT_CFLAGS) &
-	/fh=$(OBJS)\testprec_test.pch $(__EXCEPTIONSFLAG) $(__EXCEPTIONSFLAG_0) &
-	$(CPPFLAGS) $(CXXFLAGS)
+TEST_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) &
+	$(__RUNTIME_LIBS) -d__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) &
+	$(__UNICODE_DEFINE_p) -i=.\..\include -i=$(SETUPHDIR) -wx -wcd=549 -wcd=656 &
+	-wcd=657 -wcd=667 -i=. $(__DLLFLAG_p) -dwxUSE_GUI=0 $(CPPUNIT_CFLAGS) &
+	/fh=$(OBJS)\testprec_test.pch $(__RTTIFLAG) $(__EXCEPTIONSFLAG) $(CPPFLAGS) &
+	$(CXXFLAGS)
 TEST_OBJECTS =  &
 	$(OBJS)\test_dummy.obj &
 	$(OBJS)\test_test.obj &
@@ -233,15 +240,16 @@ TEST_OBJECTS =  &
 	$(OBJS)\test_largefile.obj &
 	$(OBJS)\test_memstream.obj &
 	$(OBJS)\test_sstream.obj &
+	$(OBJS)\test_tempfile.obj &
 	$(OBJS)\test_textstreamtest.obj &
 	$(OBJS)\test_zlibstream.obj &
 	$(OBJS)\test_uris.obj
-TEST_GUI_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) -bm $(__RUNTIME_LIBS) &
-	-d__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__UNICODE_DEFINE_p) &
-	-i=.\..\include -i=$(SETUPHDIR) -wx -wcd=549 -wcd=656 -wcd=657 -wcd=667 -i=. &
-	$(__DLLFLAG_p) -i=.\..\samples -dNOPCH $(CPPUNIT_CFLAGS) &
-	/fh=$(OBJS)\testprec_test_gui.pch $(__EXCEPTIONSFLAG) &
-	$(__EXCEPTIONSFLAG_0) $(CPPFLAGS) $(CXXFLAGS)
+TEST_GUI_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) &
+	$(__RUNTIME_LIBS) -d__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) &
+	$(__UNICODE_DEFINE_p) -i=.\..\include -i=$(SETUPHDIR) -wx -wcd=549 -wcd=656 &
+	-wcd=657 -wcd=667 -i=. $(__DLLFLAG_p) -i=.\..\samples -dNOPCH &
+	$(CPPUNIT_CFLAGS) /fh=$(OBJS)\testprec_test_gui.pch $(__RTTIFLAG) &
+	$(__EXCEPTIONSFLAG) $(CPPFLAGS) $(CXXFLAGS)
 TEST_GUI_OBJECTS =  &
 	$(OBJS)\test_gui_dummy.obj &
 	$(OBJS)\test_gui_test.obj &
@@ -382,6 +390,9 @@ $(OBJS)\test_memstream.obj :  .AUTODEPEND .\streams\memstream.cpp
 $(OBJS)\test_sstream.obj :  .AUTODEPEND .\streams\sstream.cpp
 	$(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $<
 
+$(OBJS)\test_tempfile.obj :  .AUTODEPEND .\streams\tempfile.cpp
+	$(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $<
+
 $(OBJS)\test_textstreamtest.obj :  .AUTODEPEND .\streams\textstreamtest.cpp
 	$(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $<
 
diff --git a/tests/streams/bstream.cpp b/tests/streams/bstream.cpp
index 82961cfbd6..5b1e307e45 100644
--- a/tests/streams/bstream.cpp
+++ b/tests/streams/bstream.cpp
@@ -50,6 +50,7 @@ Test *StreamCase::suite()
     STREAM_REGISTER_SUB_SUITE(strStream);
     STREAM_REGISTER_SUB_SUITE(fileStream);
     STREAM_REGISTER_SUB_SUITE(ffileStream);
+    STREAM_REGISTER_SUB_SUITE(tempStream);
     STREAM_REGISTER_SUB_SUITE(zlibStream);
 
     extern CppUnit::Test* GetlargeFileSuite();
diff --git a/tests/streams/tempfile.cpp b/tests/streams/tempfile.cpp
new file mode 100644
index 0000000000..9fe28801e2
--- /dev/null
+++ b/tests/streams/tempfile.cpp
@@ -0,0 +1,107 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        tests/streams/tempfile.cpp
+// Purpose:     Test wxTempFileOutputStream
+// Author:      Mike Wetherell
+// RCS-ID:      $Id$
+// Copyright:   (c) 2005 Mike Wetherell
+// Licence:     wxWidgets licence
+///////////////////////////////////////////////////////////////////////////////
+
+#include "testprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers
+#ifndef WX_PRECOMP
+    #include "wx/wx.h"
+#endif
+
+#include "wx/wfstream.h"
+#include "wx/filename.h"
+#include "bstream.h"
+
+#if wxUSE_STREAMS && wxUSE_FILE
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Self deleting test file
+
+class TestFile
+{
+public:
+    TestFile();
+    ~TestFile() { if (wxFileExists(m_name)) wxRemoveFile(m_name); }
+    wxString GetName() const { return m_name; }
+private:
+    wxString m_name;
+};
+
+// Initialise with a test pattern so we can see if the file is replaced
+//
+TestFile::TestFile()
+{
+    wxFile file;
+    m_name = wxFileName::CreateTempFileName(_T("wxtest"), &file);
+    file.Write("Before", 6);
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// The test case
+
+class tempStream : public CppUnit::TestCase
+{
+    CPPUNIT_TEST_SUITE(tempStream);
+        CPPUNIT_TEST(DoNothing);
+        CPPUNIT_TEST(Close);
+        CPPUNIT_TEST(Commit);
+        CPPUNIT_TEST(Discard);
+    CPPUNIT_TEST_SUITE_END();
+
+    void DoNothing() { DoTest(DONOTHING, false); }
+    void Close()     { DoTest(CLOSE, true); }
+    void Commit()    { DoTest(COMMIT, true); }
+    void Discard()   { DoTest(DISCARD, false); }
+
+    enum Action { DONOTHING, CLOSE, COMMIT, DISCARD };
+    void DoTest(Action action, bool shouldHaveCommited);
+};
+
+// the common test code
+//
+void tempStream::DoTest(Action action, bool shouldHaveCommited)
+{
+    TestFile temp;
+
+    {
+        wxTempFileOutputStream out(temp.GetName());
+        out.Write("Affer", 5);
+        CPPUNIT_ASSERT(out.SeekO(2) == 2);
+        out.Write("t", 1);
+        CPPUNIT_ASSERT(out.IsSeekable());
+        CPPUNIT_ASSERT(out.GetLength() == 5);
+        CPPUNIT_ASSERT(out.TellO() == 3);
+
+        switch (action) {
+            case DONOTHING: break;
+            case COMMIT:    out.Commit(); break;
+            case DISCARD:   out.Discard(); break;
+            case CLOSE:     out.Close();
+        }
+    }
+
+    wxFileInputStream in(temp.GetName());
+    char buf[32];
+    in.Read(buf, sizeof(buf));
+    buf[in.LastRead()] = 0;
+    CPPUNIT_ASSERT(strcmp(buf, shouldHaveCommited ? "After" : "Before") == 0);
+}
+
+
+// Register the stream sub suite, by using some stream helper macro.
+// Note: Don't forget to connect it to the base suite (See: bstream.cpp => StreamCase::suite())
+STREAM_TEST_SUBSUITE_NAMED_REGISTRATION(tempStream)
+
+#endif // wxUSE_STREAMS && wxUSE_FILE
diff --git a/tests/test.bkl b/tests/test.bkl
index 16bb6666af..0dbfbf1924 100644
--- a/tests/test.bkl
+++ b/tests/test.bkl
@@ -51,6 +51,7 @@
             streams/largefile.cpp
             streams/memstream.cpp
             streams/sstream.cpp
+            streams/tempfile.cpp
             streams/textstreamtest.cpp
             streams/zlibstream.cpp
             uris/uris.cpp
diff --git a/tests/test_test.dsp b/tests/test_test.dsp
index 8d2a6df7d8..7999a9631b 100644
--- a/tests/test_test.dsp
+++ b/tests/test_test.dsp
@@ -537,6 +537,10 @@ SOURCE=.\strings\strings.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\streams\tempfile.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\test.cpp
 # End Source File
 # Begin Source File
-- 
2.45.2

