remove last ofstream
authorRobin Gareus <robin@gareus.org>
Tue, 13 Oct 2015 07:50:38 +0000 (09:50 +0200)
committerRobin Gareus <robin@gareus.org>
Tue, 13 Oct 2015 07:55:53 +0000 (09:55 +0200)
libs/ardour/ardour/export_handler.h
libs/ardour/export_handler.cc

index 526d32b4c6614b36aab7ee016292e43b88bdb3f2..3d92888d60f8db4f544c78d23f132e75ce00f171 100644 (file)
 #define __ardour_export_handler_h__
 
 #include <map>
-#include <fstream>
 
 #include <boost/operators.hpp>
 #include <boost/shared_ptr.hpp>
 
+#include "pbd/gstdio_compat.h"
+
 #include "ardour/export_pointers.h"
 #include "ardour/session.h"
 #include "ardour/libardour_visibility.h"
 #include "ardour/types.h"
 #include "pbd/signals.h"
 
+#include "i18n.h"
+
 namespace AudioGrapher {
        class BroadcastInfo;
 }
@@ -156,13 +159,31 @@ class LIBARDOUR_API ExportHandler : public ExportElementFactory, public sigc::tr
        struct CDMarkerStatus {
                CDMarkerStatus (std::string out_file, ExportTimespanPtr timespan,
                                ExportFormatSpecPtr format, std::string filename)
-                 : out (out_file.c_str()), timespan (timespan), format (format), filename (filename), marker(0)
-                 , track_number (1), track_position (0), track_duration (0), track_start_frame (0)
-                 , index_number (1), index_position (0)
+                 : path (out_file)
+                 , timespan (timespan)
+                 , format (format)
+                 , filename (filename)
+                 , marker(0)
+                 , track_number (1)
+                 , track_position (0)
+                 , track_duration (0)
+                 , track_start_frame (0)
+                 , index_number (1)
+                 , index_position (0)
                  {}
 
+               ~CDMarkerStatus () {
+                       if (!g_file_set_contents (path.c_str(), out.str().c_str(), -1, NULL)) {
+                               PBD::error << string_compose(_("Editor: cannot open \"%1\" as export file for CD marker file"), path) << endmsg;
+                       }
+
+               }
+
+               /* I/O */
+               std::string         path;
+               std::stringstream   out;
+
                /* General info */
-               std::ofstream  out;
                ExportTimespanPtr   timespan;
                ExportFormatSpecPtr format;
                std::string         filename;
index a9066ee6e71dd193f1cea94c95047b2f5d44e540..f53f270918fba0c572b912331f73d6ecf25f1dc2 100644 (file)
@@ -425,11 +425,6 @@ ExportHandler::export_cd_marker_file (ExportTimespanPtr timespan, ExportFormatSp
 
                CDMarkerStatus status (filepath, timespan, file_format, filename);
 
-               if (!status.out) {
-                       error << string_compose(_("Editor: cannot open \"%1\" as export file for CD marker file"), filepath) << endmsg;
-                       return;
-               }
-
                (this->*header_func) (status);
 
                /* Get locations and sort */