Move functions in pbd/clear_dir.h/cc into pbd/file_utils.h/cc
[ardour.git] / libs / ardour / midi_source.cc
index 8034634ba7da01c7aa47724c47dfb2174ad09603..655222413aa0a5f5d836c6121c5511a99d8569c0 100644 (file)
@@ -332,31 +332,9 @@ MidiSource::mark_streaming_write_completed ()
        mark_midi_streaming_write_completed (Evoral::Sequence<Evoral::MusicalTime>::DeleteStuckNotes);
 }
 
-boost::shared_ptr<MidiSource>
-MidiSource::clone (const string& path, Evoral::MusicalTime begin, Evoral::MusicalTime end)
+int
+MidiSource::write_to (boost::shared_ptr<MidiSource> newsrc, Evoral::MusicalTime begin, Evoral::MusicalTime end)
 {
-       string newname = PBD::basename_nosuffix(_name.val());
-       string newpath;
-
-       if (path.empty()) {
-
-               /* get a new name for the MIDI file we're going to write to
-                */
-               
-               do {
-                       newname = bump_name_once (newname, '-');
-                       newpath = Glib::build_filename (_session.session_directory().midi_path(), newname + ".mid");
-                       
-               } while (Glib::file_test (newpath, Glib::FILE_TEST_EXISTS));
-       } else {
-               /* caller must check for pre-existing file */
-               newpath = path;
-       }
-
-       boost::shared_ptr<MidiSource> newsrc = boost::dynamic_pointer_cast<MidiSource>(
-               SourceFactory::createWritable(DataType::MIDI, _session,
-                                             newpath, false, _session.frame_rate()));
-
        newsrc->set_timeline_position(_timeline_position);
        newsrc->copy_interpolation_from (this);
        newsrc->copy_automation_state_from (this);
@@ -369,7 +347,7 @@ MidiSource::clone (const string& path, Evoral::MusicalTime begin, Evoral::Musica
                }
        } else {
                error << string_compose (_("programming error: %1"), X_("no model for MidiSource during ::clone()"));
-               return boost::shared_ptr<MidiSource>();
+               return -1;
        }
 
        newsrc->flush_midi();
@@ -386,7 +364,7 @@ MidiSource::clone (const string& path, Evoral::MusicalTime begin, Evoral::Musica
 
        boost::dynamic_pointer_cast<FileSource> (newsrc)->prevent_deletion ();
 
-       return newsrc;
+       return 0;
 }
 
 void