Browse Source

added close_output method

Chris Brunner 16 years ago
parent
commit
367cb1a1ff

+ 19 - 0
pandatool/src/progbase/withOutputFile.cxx

@@ -106,6 +106,25 @@ get_output() {
   return *_output_ptr;
   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
 //     Function: WithOutputFile::has_output_filename
 //       Access: Public
 //       Access: Public

+ 1 - 0
pandatool/src/progbase/withOutputFile.h

@@ -37,6 +37,7 @@ public:
   virtual ~WithOutputFile();
   virtual ~WithOutputFile();
 
 
   ostream &get_output();
   ostream &get_output();
+  void close_output();
   bool has_output_filename() const;
   bool has_output_filename() const;
   Filename get_output_filename() const;
   Filename get_output_filename() const;