From 367cb1a1ffe994aa469cd80a11ae44e8b1fdb725 Mon Sep 17 00:00:00 2001 From: Chris Brunner Date: Mon, 9 Nov 2009 22:50:11 +0000 Subject: [PATCH] added close_output method --- pandatool/src/progbase/withOutputFile.cxx | 19 +++++++++++++++++++ pandatool/src/progbase/withOutputFile.h | 1 + 2 files changed, 20 insertions(+) diff --git a/pandatool/src/progbase/withOutputFile.cxx b/pandatool/src/progbase/withOutputFile.cxx index 67056bba20..61a786ff07 100644 --- a/pandatool/src/progbase/withOutputFile.cxx +++ b/pandatool/src/progbase/withOutputFile.cxx @@ -106,6 +106,25 @@ get_output() { return *_output_ptr; } +//////////////////////////////////////////////////////////////////// +// Function: WithOutputFile::close_output +// Access: Public +// Description: Closes the output stream previously opened by +// get_output(). A subsequent call to get_output() will +// open a new stream. +//////////////////////////////////////////////////////////////////// +void WithOutputFile:: +close_output() { + if (_owns_output_ptr) { + delete _output_ptr; + _owns_output_ptr = false; + } + _output_ptr = NULL; + _output_stream.close(); +} + + + //////////////////////////////////////////////////////////////////// // Function: WithOutputFile::has_output_filename // Access: Public diff --git a/pandatool/src/progbase/withOutputFile.h b/pandatool/src/progbase/withOutputFile.h index 59ae449c23..f2f9009a5d 100644 --- a/pandatool/src/progbase/withOutputFile.h +++ b/pandatool/src/progbase/withOutputFile.h @@ -37,6 +37,7 @@ public: virtual ~WithOutputFile(); ostream &get_output(); + void close_output(); bool has_output_filename() const; Filename get_output_filename() const;