\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}
\input tcpconn.tex
\input tcpservr.tex
\input tempfile.tex
+\input tempfilestrm.tex
\input text.tex
\input txtdatob.tex
\input txtdrptg.tex
\wxheading{See also:}
-\helpref{wxFile}{wxfile}
+\helpref{wxFile}{wxfile}\\
+\helpref{wxTempFileOutputStream}{wxtempfileoutputstream}
\latexignore{\rtfignore{\wxheading{Members}}}
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}}
--- /dev/null
+%
+% 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.
// 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; }
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
{
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
// ----------------------------------------------------------------------------
test_largefile.o \
test_memstream.o \
test_sstream.o \
+ test_tempfile.o \
test_textstreamtest.o \
test_zlibstream.o \
test_uris.o
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
# =========================================================================
# 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!
# =========================================================================
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 \
$(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 \
!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
$(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
$(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) $**
# =========================================================================
# 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!
# =========================================================================
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 \
$(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 \
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__
-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:
$(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) $<
# =========================================================================
# 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!
# =========================================================================
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 \
$(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 \
!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
!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
!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__
$(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) $**
# =========================================================================
# 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!
# =========================================================================
!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
!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
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 &
$(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 &
$(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) $<
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();
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// 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
streams/largefile.cpp
streams/memstream.cpp
streams/sstream.cpp
+ streams/tempfile.cpp
streams/textstreamtest.cpp
streams/zlibstream.cpp
uris/uris.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