changeset 531:38b1ddf18d4b

* Try to avoid leaving output files open after completion
author Chris Cannam
date Tue, 20 Jan 2009 18:11:10 +0000
parents 1d3fc01edc03
children 59dd6d1bcfb0
files transform/FileFeatureWriter.cpp transform/FileFeatureWriter.h
diffstat 2 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/transform/FileFeatureWriter.cpp	Tue Jan 20 18:10:56 2009 +0000
+++ b/transform/FileFeatureWriter.cpp	Tue Jan 20 18:11:10 2009 +0000
@@ -285,3 +285,23 @@
     }
 }
 
+
+void
+FileFeatureWriter::finish()
+{
+    cerr << "FileFeatureWriter::finish()" << endl;
+
+    if (m_singleFileName != "" || m_stdout) return;
+
+    while (!m_streams.empty()) {
+        m_streams.begin()->second->flush();
+        delete m_streams.begin()->second;
+        m_streams.erase(m_streams.begin());
+    }
+    while (!m_files.empty()) {
+        delete m_files.begin()->second;
+        m_files.erase(m_files.begin());
+    }
+    m_prevstream = 0;
+}
+
--- a/transform/FileFeatureWriter.h	Tue Jan 20 18:10:56 2009 +0000
+++ b/transform/FileFeatureWriter.h	Tue Jan 20 18:11:10 2009 +0000
@@ -43,6 +43,7 @@
     virtual void setParameters(map<string, string> &params);
 
     virtual void flush();
+    virtual void finish();
 
 protected:
     enum FileWriteSupport {