Add wxTempFileOutputStream

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32796 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Michael Wetherell 2005-03-13 16:20:51 +00:00
parent 5a053c22d8
commit e126517457
16 changed files with 372 additions and 66 deletions

View File

@ -493,6 +493,7 @@ libraries, and to provide enhanced functionality.
\twocolitem{\helpref{wxFileOutputStream}{wxfileoutputstream}}{File output stream class} \twocolitem{\helpref{wxFileOutputStream}{wxfileoutputstream}}{File output stream class}
\twocolitem{\helpref{wxFFileInputStream}{wxffileinputstream}}{Another file input stream class} \twocolitem{\helpref{wxFFileInputStream}{wxffileinputstream}}{Another file input stream class}
\twocolitem{\helpref{wxFFileOutputStream}{wxffileoutputstream}}{Another file output 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{wxStringInputStream}{wxstringinputstream}}{String input stream class}
\twocolitem{\helpref{wxStringOutputStream}{wxstringoutputstream}}{String output stream class} \twocolitem{\helpref{wxStringOutputStream}{wxstringoutputstream}}{String output stream class}
\twocolitem{\helpref{wxZlibInputStream}{wxzlibinputstream}}{Zlib (compression) input stream class} \twocolitem{\helpref{wxZlibInputStream}{wxzlibinputstream}}{Zlib (compression) input stream class}

View File

@ -323,6 +323,7 @@
\input tcpconn.tex \input tcpconn.tex
\input tcpservr.tex \input tcpservr.tex
\input tempfile.tex \input tempfile.tex
\input tempfilestrm.tex
\input text.tex \input text.tex
\input txtdatob.tex \input txtdatob.tex
\input txtdrptg.tex \input txtdrptg.tex

View File

@ -43,7 +43,8 @@ No base class
\wxheading{See also:} \wxheading{See also:}
\helpref{wxFile}{wxfile} \helpref{wxFile}{wxfile}\\
\helpref{wxTempFileOutputStream}{wxtempfileoutputstream}
\latexignore{\rtfignore{\wxheading{Members}}} \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. 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} \membersection{wxTempFile::Write}\label{wxtempfilewrite}
\func{bool}{Write}{\param{const void }{*p}, \param{size\_t }{n}} \func{bool}{Write}{\param{const void }{*p}, \param{size\_t }{n}}

View File

@ -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.

View File

@ -164,6 +164,13 @@ public:
// is the file opened? // is the file opened?
bool IsOpened() const { return m_file.IsOpened(); } 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) // 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; } bool Write(const void *p, size_t n) { return m_file.Write(p, n) == n; }

View File

@ -88,6 +88,31 @@ protected:
DECLARE_NO_COPY_CLASS(wxFileOutputStream) 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, class WXDLLIMPEXP_BASE wxFileStream : public wxFileInputStream,
public wxFileOutputStream public wxFileOutputStream
{ {

View File

@ -183,6 +183,33 @@ wxFileOffset wxFileOutputStream::GetLength() const
return m_file->Length(); 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 // wxFileStream
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -71,6 +71,7 @@ TEST_OBJECTS = \
test_largefile.o \ test_largefile.o \
test_memstream.o \ test_memstream.o \
test_sstream.o \ test_sstream.o \
test_tempfile.o \
test_textstreamtest.o \ test_textstreamtest.o \
test_zlibstream.o \ test_zlibstream.o \
test_uris.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) test_sstream.o: $(srcdir)/streams/sstream.cpp $(TEST_ODEP)
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/streams/sstream.cpp $(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) test_textstreamtest.o: $(srcdir)/streams/textstreamtest.cpp $(TEST_ODEP)
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/streams/textstreamtest.cpp $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/streams/textstreamtest.cpp

View File

@ -1,6 +1,6 @@
# ========================================================================= # =========================================================================
# This makefile was generated by # 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! # Do not modify, all changes will be overwritten!
# ========================================================================= # =========================================================================
@ -28,10 +28,10 @@ LIBDIRNAME = .\..\lib\bcc_$(LIBTYPE_SUFFIX)$(CFG)
SETUPHDIR = \ SETUPHDIR = \
$(LIBDIRNAME)\$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG) $(LIBDIRNAME)\$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)
TEST_CXXFLAGS = $(__RUNTIME_LIBS) -I$(BCCDIR)\include $(__DEBUGINFO) \ TEST_CXXFLAGS = $(__RUNTIME_LIBS) -I$(BCCDIR)\include $(__DEBUGINFO) \
$(__OPTIMIZEFLAG) -tWM -D__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) \ $(__OPTIMIZEFLAG) $(__THREADSFLAG_0) -D__WXMSW__ $(__WXUNIV_DEFINE_p) \
$(__UNICODE_DEFINE_p) -I.\..\include -I$(SETUPHDIR) -I. $(__DLLFLAG_p) \ $(__DEBUG_DEFINE_p) $(__UNICODE_DEFINE_p) -I.\..\include -I$(SETUPHDIR) -I. \
-DwxUSE_GUI=0 $(CPPUNIT_CFLAGS) -Hu -H=$(OBJS)\testprec_test.csm $(CPPFLAGS) \ $(__DLLFLAG_p) -DwxUSE_GUI=0 $(CPPUNIT_CFLAGS) -Hu \
$(CXXFLAGS) -H=$(OBJS)\testprec_test.csm $(CPPFLAGS) $(CXXFLAGS)
TEST_OBJECTS = \ TEST_OBJECTS = \
$(OBJS)\test_dummy.obj \ $(OBJS)\test_dummy.obj \
$(OBJS)\test_test.obj \ $(OBJS)\test_test.obj \
@ -62,13 +62,14 @@ TEST_OBJECTS = \
$(OBJS)\test_largefile.obj \ $(OBJS)\test_largefile.obj \
$(OBJS)\test_memstream.obj \ $(OBJS)\test_memstream.obj \
$(OBJS)\test_sstream.obj \ $(OBJS)\test_sstream.obj \
$(OBJS)\test_tempfile.obj \
$(OBJS)\test_textstreamtest.obj \ $(OBJS)\test_textstreamtest.obj \
$(OBJS)\test_zlibstream.obj \ $(OBJS)\test_zlibstream.obj \
$(OBJS)\test_uris.obj $(OBJS)\test_uris.obj
TEST_GUI_CXXFLAGS = $(__RUNTIME_LIBS) -I$(BCCDIR)\include $(__DEBUGINFO) \ TEST_GUI_CXXFLAGS = $(__RUNTIME_LIBS) -I$(BCCDIR)\include $(__DEBUGINFO) \
$(__OPTIMIZEFLAG) -tWM -D__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) \ $(__OPTIMIZEFLAG) $(__THREADSFLAG_0) -D__WXMSW__ $(__WXUNIV_DEFINE_p) \
$(__UNICODE_DEFINE_p) -I.\..\include -I$(SETUPHDIR) -I. $(__DLLFLAG_p) \ $(__DEBUG_DEFINE_p) $(__UNICODE_DEFINE_p) -I.\..\include -I$(SETUPHDIR) -I. \
-I.\..\samples -DNOPCH $(CPPUNIT_CFLAGS) -Hu \ $(__DLLFLAG_p) -I.\..\samples -DNOPCH $(CPPUNIT_CFLAGS) -Hu \
-H=$(OBJS)\testprec_test_gui.csm $(CPPFLAGS) $(CXXFLAGS) -H=$(OBJS)\testprec_test_gui.csm $(CPPFLAGS) $(CXXFLAGS)
TEST_GUI_OBJECTS = \ TEST_GUI_OBJECTS = \
$(OBJS)\test_gui_dummy.obj \ $(OBJS)\test_gui_dummy.obj \
@ -144,6 +145,18 @@ __OPTIMIZEFLAG = -Od
!if "$(BUILD)" == "release" !if "$(BUILD)" == "release"
__OPTIMIZEFLAG = -O2 __OPTIMIZEFLAG = -O2
!endif !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" !if "$(RUNTIME_LIBS)" == "dynamic"
__RUNTIME_LIBS = -tWR __RUNTIME_LIBS = -tWR
!endif !endif
@ -232,13 +245,13 @@ clean:
$(OBJS)\test.exe: $(OBJS)\test_dummy.obj $(TEST_OBJECTS) $(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) @&&| 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" !if "$(USE_GUI)" == "1"
$(OBJS)\test_gui.exe: $(OBJS)\test_gui_dummy.obj $(TEST_GUI_OBJECTS) $(OBJS)\test_gui_sample.res $(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 @&&| 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 !endif
@ -333,6 +346,9 @@ $(OBJS)\test_memstream.obj: .\streams\memstream.cpp
$(OBJS)\test_sstream.obj: .\streams\sstream.cpp $(OBJS)\test_sstream.obj: .\streams\sstream.cpp
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $** $(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 $(OBJS)\test_textstreamtest.obj: .\streams\textstreamtest.cpp
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $** $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) $**

View File

@ -1,6 +1,6 @@
# ========================================================================= # =========================================================================
# This makefile was generated by # 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! # Do not modify, all changes will be overwritten!
# ========================================================================= # =========================================================================
@ -21,8 +21,8 @@ SETUPHDIR = \
TEST_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(GCCFLAGS) -DHAVE_W32API_H \ TEST_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(GCCFLAGS) -DHAVE_W32API_H \
-D__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__UNICODE_DEFINE_p) \ -D__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__UNICODE_DEFINE_p) \
-I.\..\include -I$(SETUPHDIR) -W -Wall -I. $(__DLLFLAG_p) -DwxUSE_GUI=0 \ -I.\..\include -I$(SETUPHDIR) -W -Wall -I. $(__DLLFLAG_p) -DwxUSE_GUI=0 \
$(CPPUNIT_CFLAGS) $(__EXCEPTIONSFLAG) $(__EXCEPTIONSFLAG_0) \ $(CPPUNIT_CFLAGS) $(__RTTIFLAG) $(__EXCEPTIONSFLAG) -Wno-ctor-dtor-privacy \
-Wno-ctor-dtor-privacy $(CPPFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(CXXFLAGS)
TEST_OBJECTS = \ TEST_OBJECTS = \
$(OBJS)\test_dummy.o \ $(OBJS)\test_dummy.o \
$(OBJS)\test_test.o \ $(OBJS)\test_test.o \
@ -53,14 +53,15 @@ TEST_OBJECTS = \
$(OBJS)\test_largefile.o \ $(OBJS)\test_largefile.o \
$(OBJS)\test_memstream.o \ $(OBJS)\test_memstream.o \
$(OBJS)\test_sstream.o \ $(OBJS)\test_sstream.o \
$(OBJS)\test_tempfile.o \
$(OBJS)\test_textstreamtest.o \ $(OBJS)\test_textstreamtest.o \
$(OBJS)\test_zlibstream.o \ $(OBJS)\test_zlibstream.o \
$(OBJS)\test_uris.o $(OBJS)\test_uris.o
TEST_GUI_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(GCCFLAGS) \ TEST_GUI_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(GCCFLAGS) \
-DHAVE_W32API_H -D__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) \ -DHAVE_W32API_H -D__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) \
$(__UNICODE_DEFINE_p) -I.\..\include -I$(SETUPHDIR) -W -Wall -I. \ $(__UNICODE_DEFINE_p) -I.\..\include -I$(SETUPHDIR) -W -Wall -I. \
$(__DLLFLAG_p) -I.\..\samples -DNOPCH $(CPPUNIT_CFLAGS) $(__EXCEPTIONSFLAG) \ $(__DLLFLAG_p) -I.\..\samples -DNOPCH $(CPPUNIT_CFLAGS) $(__RTTIFLAG) \
$(__EXCEPTIONSFLAG_0) -Wno-ctor-dtor-privacy $(CPPFLAGS) $(CXXFLAGS) $(__EXCEPTIONSFLAG) -Wno-ctor-dtor-privacy $(CPPFLAGS) $(CXXFLAGS)
TEST_GUI_OBJECTS = \ TEST_GUI_OBJECTS = \
$(OBJS)\test_gui_sample_rc.o \ $(OBJS)\test_gui_sample_rc.o \
$(OBJS)\test_gui_dummy.o \ $(OBJS)\test_gui_dummy.o \
@ -143,18 +144,24 @@ endif
ifeq ($(BUILD),release) ifeq ($(BUILD),release)
__OPTIMIZEFLAG = -O2 __OPTIMIZEFLAG = -O2
endif endif
ifeq ($(USE_THREADS),0)
__THREADSFLAG =
endif
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) ifeq ($(USE_EXCEPTIONS),0)
__EXCEPTIONSFLAG = -fno-rtti __EXCEPTIONSFLAG = -fno-exceptions
endif endif
ifeq ($(USE_EXCEPTIONS),1) ifeq ($(USE_EXCEPTIONS),1)
__EXCEPTIONSFLAG = __EXCEPTIONSFLAG =
endif endif
ifeq ($(USE_EXCEPTIONS),0)
__EXCEPTIONSFLAG_0 = -fno-exceptions
endif
ifeq ($(USE_EXCEPTIONS),1)
__EXCEPTIONSFLAG_0 =
endif
ifeq ($(WXUNIV),1) ifeq ($(WXUNIV),1)
__WXUNIV_DEFINE_p = -D__WXUNIVERSAL__ __WXUNIV_DEFINE_p = -D__WXUNIVERSAL__
endif endif
@ -224,11 +231,11 @@ clean:
-if exist $(OBJS)\test_gui.exe del $(OBJS)\test_gui.exe -if exist $(OBJS)\test_gui.exe del $(OBJS)\test_gui.exe
$(OBJS)\test.exe: $(TEST_OBJECTS) $(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) ifeq ($(USE_GUI),1)
$(OBJS)\test_gui.exe: $(TEST_GUI_OBJECTS) $(OBJS)\test_gui_sample_rc.o $(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 endif
data: data:
@ -322,6 +329,9 @@ $(OBJS)\test_memstream.o: ./streams/memstream.cpp
$(OBJS)\test_sstream.o: ./streams/sstream.cpp $(OBJS)\test_sstream.o: ./streams/sstream.cpp
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $< $(CXX) -c -o $@ $(TEST_CXXFLAGS) $<
$(OBJS)\test_tempfile.o: ./streams/tempfile.cpp
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $<
$(OBJS)\test_textstreamtest.o: ./streams/textstreamtest.cpp $(OBJS)\test_textstreamtest.o: ./streams/textstreamtest.cpp
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $< $(CXX) -c -o $@ $(TEST_CXXFLAGS) $<

View File

@ -1,6 +1,6 @@
# ========================================================================= # =========================================================================
# This makefile was generated by # 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! # Do not modify, all changes will be overwritten!
# ========================================================================= # =========================================================================
@ -18,12 +18,12 @@ OBJS = \
LIBDIRNAME = .\..\lib\vc_$(LIBTYPE_SUFFIX)$(CFG) LIBDIRNAME = .\..\lib\vc_$(LIBTYPE_SUFFIX)$(CFG)
SETUPHDIR = \ SETUPHDIR = \
$(LIBDIRNAME)\$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG) $(LIBDIRNAME)\$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)
TEST_CXXFLAGS = /M$(__RUNTIME_LIBS)$(__DEBUGRUNTIME_3) /DWIN32 $(__DEBUGINFO) \ TEST_CXXFLAGS = /M$(__RUNTIME_LIBS_7)$(__DEBUGRUNTIME_3) /DWIN32 \
/Fd$(OBJS)\test.pdb $(____DEBUGRUNTIME_2_p) $(__OPTIMIZEFLAG) \ $(__DEBUGINFO) /Fd$(OBJS)\test.pdb $(____DEBUGRUNTIME_2_p) \
$(__NO_VC_CRTDBG_p) /D__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) \ $(__OPTIMIZEFLAG) $(__NO_VC_CRTDBG_p) /D__WXMSW__ $(__WXUNIV_DEFINE_p) \
$(__UNICODE_DEFINE_p) /I.\..\include /I$(SETUPHDIR) /W4 /I. $(__DLLFLAG_p) \ $(__DEBUG_DEFINE_p) $(__UNICODE_DEFINE_p) /I.\..\include /I$(SETUPHDIR) /W4 \
/D_CONSOLE /DwxUSE_GUI=0 $(CPPUNIT_CFLAGS) $(__EXCEPTIONSFLAG) \ /I. $(__DLLFLAG_p) /D_CONSOLE /DwxUSE_GUI=0 $(CPPUNIT_CFLAGS) $(__RTTIFLAG) \
$(__EXCEPTIONSFLAG_0) /Yu"testprec.h" /Fp"$(OBJS)\testprec_test.pch" \ $(__EXCEPTIONSFLAG) /Yu"testprec.h" /Fp"$(OBJS)\testprec_test.pch" \
$(CPPFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(CXXFLAGS)
TEST_OBJECTS = \ TEST_OBJECTS = \
$(OBJS)\test_dummy.obj \ $(OBJS)\test_dummy.obj \
@ -55,15 +55,16 @@ TEST_OBJECTS = \
$(OBJS)\test_largefile.obj \ $(OBJS)\test_largefile.obj \
$(OBJS)\test_memstream.obj \ $(OBJS)\test_memstream.obj \
$(OBJS)\test_sstream.obj \ $(OBJS)\test_sstream.obj \
$(OBJS)\test_tempfile.obj \
$(OBJS)\test_textstreamtest.obj \ $(OBJS)\test_textstreamtest.obj \
$(OBJS)\test_zlibstream.obj \ $(OBJS)\test_zlibstream.obj \
$(OBJS)\test_uris.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) \ $(__DEBUGINFO) /Fd$(OBJS)\test_gui.pdb $(____DEBUGRUNTIME_16_p) \
$(__OPTIMIZEFLAG) $(__NO_VC_CRTDBG_p) /D__WXMSW__ $(__WXUNIV_DEFINE_p) \ $(__OPTIMIZEFLAG) $(__NO_VC_CRTDBG_p) /D__WXMSW__ $(__WXUNIV_DEFINE_p) \
$(__DEBUG_DEFINE_p) $(__UNICODE_DEFINE_p) /I.\..\include /I$(SETUPHDIR) /W4 \ $(__DEBUG_DEFINE_p) $(__UNICODE_DEFINE_p) /I.\..\include /I$(SETUPHDIR) /W4 \
/I. $(__DLLFLAG_p) /I.\..\samples /DNOPCH $(CPPUNIT_CFLAGS) /D_CONSOLE \ /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) /Fp"$(OBJS)\testprec_test_gui.pch" $(CPPFLAGS) $(CXXFLAGS)
TEST_GUI_OBJECTS = \ TEST_GUI_OBJECTS = \
$(OBJS)\test_gui_sample.res \ $(OBJS)\test_gui_sample.res \
@ -126,6 +127,12 @@ __DEBUGRUNTIME_3 = d
!if "$(DEBUG_RUNTIME_LIBS)" == "default" !if "$(DEBUG_RUNTIME_LIBS)" == "default"
__DEBUGRUNTIME_3 = $(__DEBUGINFO_2) __DEBUGRUNTIME_3 = $(__DEBUGINFO_2)
!endif !endif
!if "$(RUNTIME_LIBS)" == "dynamic"
__RUNTIME_LIBS_7 = D
!endif
!if "$(RUNTIME_LIBS)" == "static"
__RUNTIME_LIBS_7 = $(__THREADSFLAG)
!endif
!if "$(MONOLITHIC)" == "0" !if "$(MONOLITHIC)" == "0"
__WXLIB_NET_p = \ __WXLIB_NET_p = \
wxbase$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_net.lib wxbase$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_net.lib
@ -172,6 +179,12 @@ __DEBUGRUNTIME_17 = d
!if "$(DEBUG_RUNTIME_LIBS)" == "default" !if "$(DEBUG_RUNTIME_LIBS)" == "default"
__DEBUGRUNTIME_17 = $(__DEBUGINFO_2) __DEBUGRUNTIME_17 = $(__DEBUGINFO_2)
!endif !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" !if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "0"
__NO_VC_CRTDBG_p_3 = /d __NO_VC_CRTDBG__ __NO_VC_CRTDBG_p_3 = /d __NO_VC_CRTDBG__
!endif !endif
@ -251,23 +264,23 @@ __OPTIMIZEFLAG = /Od
!if "$(BUILD)" == "release" !if "$(BUILD)" == "release"
__OPTIMIZEFLAG = /O2 __OPTIMIZEFLAG = /O2
!endif !endif
!if "$(RUNTIME_LIBS)" == "dynamic" !if "$(USE_THREADS)" == "0"
__RUNTIME_LIBS = D __THREADSFLAG = L
!endif !endif
!if "$(RUNTIME_LIBS)" == "static" !if "$(USE_THREADS)" == "1"
__RUNTIME_LIBS = T __THREADSFLAG = T
!endif
!if "$(USE_RTTI)" == "0"
__RTTIFLAG =
!endif
!if "$(USE_RTTI)" == "1"
__RTTIFLAG = /GR
!endif !endif
!if "$(USE_EXCEPTIONS)" == "0" !if "$(USE_EXCEPTIONS)" == "0"
__EXCEPTIONSFLAG = __EXCEPTIONSFLAG =
!endif !endif
!if "$(USE_EXCEPTIONS)" == "1" !if "$(USE_EXCEPTIONS)" == "1"
__EXCEPTIONSFLAG = /GR __EXCEPTIONSFLAG = /GX
!endif
!if "$(USE_EXCEPTIONS)" == "0"
__EXCEPTIONSFLAG_0 =
!endif
!if "$(USE_EXCEPTIONS)" == "1"
__EXCEPTIONSFLAG_0 = /GX
!endif !endif
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "0" !if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "0"
__NO_VC_CRTDBG_p = /D__NO_VC_CRTDBG__ __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 $(OBJS)\test_sstream.obj: .\streams\sstream.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $** $(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 $(OBJS)\test_textstreamtest.obj: .\streams\textstreamtest.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $** $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) $**

View File

@ -1,6 +1,6 @@
# ========================================================================= # =========================================================================
# This makefile was generated by # 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! # Do not modify, all changes will be overwritten!
# ========================================================================= # =========================================================================
@ -124,6 +124,13 @@ __OPTIMIZEFLAG = -od
!ifeq BUILD release !ifeq BUILD release
__OPTIMIZEFLAG = -ot -ox __OPTIMIZEFLAG = -ot -ox
!endif !endif
__THREADSFLAG =
!ifeq USE_THREADS 0
__THREADSFLAG =
!endif
!ifeq USE_THREADS 1
__THREADSFLAG = -bm
!endif
__RUNTIME_LIBS = __RUNTIME_LIBS =
!ifeq RUNTIME_LIBS dynamic !ifeq RUNTIME_LIBS dynamic
__RUNTIME_LIBS = -br __RUNTIME_LIBS = -br
@ -131,19 +138,19 @@ __RUNTIME_LIBS = -br
!ifeq RUNTIME_LIBS static !ifeq RUNTIME_LIBS static
__RUNTIME_LIBS = __RUNTIME_LIBS =
!endif !endif
__RTTIFLAG =
!ifeq USE_RTTI 0
__RTTIFLAG =
!endif
!ifeq USE_RTTI 1
__RTTIFLAG = -xr
!endif
__EXCEPTIONSFLAG = __EXCEPTIONSFLAG =
!ifeq USE_EXCEPTIONS 0 !ifeq USE_EXCEPTIONS 0
__EXCEPTIONSFLAG = __EXCEPTIONSFLAG =
!endif !endif
!ifeq USE_EXCEPTIONS 1 !ifeq USE_EXCEPTIONS 1
__EXCEPTIONSFLAG = -xr __EXCEPTIONSFLAG = -xs
!endif
__EXCEPTIONSFLAG_0 =
!ifeq USE_EXCEPTIONS 0
__EXCEPTIONSFLAG_0 =
!endif
!ifeq USE_EXCEPTIONS 1
__EXCEPTIONSFLAG_0 = -xs
!endif !endif
__WXLIB_BASE_p = __WXLIB_BASE_p =
!ifeq MONOLITHIC 0 !ifeq MONOLITHIC 0
@ -197,12 +204,12 @@ OBJS = &
LIBDIRNAME = .\..\lib\wat_$(LIBTYPE_SUFFIX)$(CFG) LIBDIRNAME = .\..\lib\wat_$(LIBTYPE_SUFFIX)$(CFG)
SETUPHDIR = & SETUPHDIR = &
$(LIBDIRNAME)\$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG) $(LIBDIRNAME)\$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)
TEST_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) -bm $(__RUNTIME_LIBS) & TEST_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) &
-d__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__UNICODE_DEFINE_p) & $(__RUNTIME_LIBS) -d__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) &
-i=.\..\include -i=$(SETUPHDIR) -wx -wcd=549 -wcd=656 -wcd=657 -wcd=667 -i=. & $(__UNICODE_DEFINE_p) -i=.\..\include -i=$(SETUPHDIR) -wx -wcd=549 -wcd=656 &
$(__DLLFLAG_p) -dwxUSE_GUI=0 $(CPPUNIT_CFLAGS) & -wcd=657 -wcd=667 -i=. $(__DLLFLAG_p) -dwxUSE_GUI=0 $(CPPUNIT_CFLAGS) &
/fh=$(OBJS)\testprec_test.pch $(__EXCEPTIONSFLAG) $(__EXCEPTIONSFLAG_0) & /fh=$(OBJS)\testprec_test.pch $(__RTTIFLAG) $(__EXCEPTIONSFLAG) $(CPPFLAGS) &
$(CPPFLAGS) $(CXXFLAGS) $(CXXFLAGS)
TEST_OBJECTS = & TEST_OBJECTS = &
$(OBJS)\test_dummy.obj & $(OBJS)\test_dummy.obj &
$(OBJS)\test_test.obj & $(OBJS)\test_test.obj &
@ -233,15 +240,16 @@ TEST_OBJECTS = &
$(OBJS)\test_largefile.obj & $(OBJS)\test_largefile.obj &
$(OBJS)\test_memstream.obj & $(OBJS)\test_memstream.obj &
$(OBJS)\test_sstream.obj & $(OBJS)\test_sstream.obj &
$(OBJS)\test_tempfile.obj &
$(OBJS)\test_textstreamtest.obj & $(OBJS)\test_textstreamtest.obj &
$(OBJS)\test_zlibstream.obj & $(OBJS)\test_zlibstream.obj &
$(OBJS)\test_uris.obj $(OBJS)\test_uris.obj
TEST_GUI_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) -bm $(__RUNTIME_LIBS) & TEST_GUI_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) &
-d__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__UNICODE_DEFINE_p) & $(__RUNTIME_LIBS) -d__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) &
-i=.\..\include -i=$(SETUPHDIR) -wx -wcd=549 -wcd=656 -wcd=657 -wcd=667 -i=. & $(__UNICODE_DEFINE_p) -i=.\..\include -i=$(SETUPHDIR) -wx -wcd=549 -wcd=656 &
$(__DLLFLAG_p) -i=.\..\samples -dNOPCH $(CPPUNIT_CFLAGS) & -wcd=657 -wcd=667 -i=. $(__DLLFLAG_p) -i=.\..\samples -dNOPCH &
/fh=$(OBJS)\testprec_test_gui.pch $(__EXCEPTIONSFLAG) & $(CPPUNIT_CFLAGS) /fh=$(OBJS)\testprec_test_gui.pch $(__RTTIFLAG) &
$(__EXCEPTIONSFLAG_0) $(CPPFLAGS) $(CXXFLAGS) $(__EXCEPTIONSFLAG) $(CPPFLAGS) $(CXXFLAGS)
TEST_GUI_OBJECTS = & TEST_GUI_OBJECTS = &
$(OBJS)\test_gui_dummy.obj & $(OBJS)\test_gui_dummy.obj &
$(OBJS)\test_gui_test.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 $(OBJS)\test_sstream.obj : .AUTODEPEND .\streams\sstream.cpp
$(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $< $(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 $(OBJS)\test_textstreamtest.obj : .AUTODEPEND .\streams\textstreamtest.cpp
$(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $< $(CXX) -zq -fo=$^@ $(TEST_CXXFLAGS) $<

View File

@ -50,6 +50,7 @@ Test *StreamCase::suite()
STREAM_REGISTER_SUB_SUITE(strStream); STREAM_REGISTER_SUB_SUITE(strStream);
STREAM_REGISTER_SUB_SUITE(fileStream); STREAM_REGISTER_SUB_SUITE(fileStream);
STREAM_REGISTER_SUB_SUITE(ffileStream); STREAM_REGISTER_SUB_SUITE(ffileStream);
STREAM_REGISTER_SUB_SUITE(tempStream);
STREAM_REGISTER_SUB_SUITE(zlibStream); STREAM_REGISTER_SUB_SUITE(zlibStream);
extern CppUnit::Test* GetlargeFileSuite(); extern CppUnit::Test* GetlargeFileSuite();

107
tests/streams/tempfile.cpp Normal file
View File

@ -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

View File

@ -51,6 +51,7 @@
streams/largefile.cpp streams/largefile.cpp
streams/memstream.cpp streams/memstream.cpp
streams/sstream.cpp streams/sstream.cpp
streams/tempfile.cpp
streams/textstreamtest.cpp streams/textstreamtest.cpp
streams/zlibstream.cpp streams/zlibstream.cpp
uris/uris.cpp uris/uris.cpp

View File

@ -537,6 +537,10 @@ SOURCE=.\strings\strings.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\streams\tempfile.cpp
# End Source File
# Begin Source File
SOURCE=.\test.cpp SOURCE=.\test.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File