fix a bunch of memory leaks
[ardour.git] / libs / ardour / smf_source.cc
index c3bc78c83dec8cc94b7f4cea564004de69fd2624..6ec7c5a78ce8318afc8890ea14df380769b91bbf 100644 (file)
 #include <errno.h>
 #include <regex.h>
 
-#include "pbd/pathscanner.h"
+#include "pbd/file_utils.h"
 #include "pbd/stl_delete.h"
 #include "pbd/strsplit.h"
 
+#include <glib/gstdio.h>
 #include <glibmm/miscutils.h>
 #include <glibmm/fileutils.h>
 
 #include "evoral/Control.hpp"
-#include "evoral/evoral/SMF.hpp"
+#include "evoral/SMF.hpp"
 
 #include "ardour/event_type_map.h"
 #include "ardour/midi_model.h"
@@ -148,7 +149,7 @@ SMFSource::SMFSource (Session& s, const XMLNode& node, bool must_exist)
 SMFSource::~SMFSource ()
 {
        if (removable()) {
-               unlink (_path.c_str());
+               ::g_unlink (_path.c_str());
        }
 }
 
@@ -717,35 +718,5 @@ SMFSource::prevent_deletion ()
   
        _flags = Flag (_flags & ~(Removable|RemovableIfEmpty|RemoveAtDestroy));
 }
-
-int
-SMFSource::rename (const string& newname)
-{
-       Glib::Threads::Mutex::Lock lm (_lock);
-       string oldpath = _path;
-       string newpath = _session.new_source_path_from_name (DataType::MIDI, newname);
-
-       if (newpath.empty()) {
-               error << string_compose (_("programming error: %1"), "cannot generate a changed file path") << endmsg;
-               return -1;
-       }
-
-       // Test whether newpath exists, if yes notify the user but continue.
-       if (Glib::file_test (newpath, Glib::FILE_TEST_EXISTS)) {
-               error << string_compose (_("Programming error! %1 tried to rename a file over another file! It's safe to continue working, but please report this to the developers."), PROGRAM_NAME) << endmsg;
-               return -1;
-       }
-
-       if (Glib::file_test (oldpath.c_str(), Glib::FILE_TEST_EXISTS)) { 
-               /* rename only needed if file exists on disk */
-               if (::rename (oldpath.c_str(), newpath.c_str()) != 0) {
-                       error << string_compose (_("cannot rename file %1 to %2 (%3)"), oldpath, newpath, strerror(errno)) << endmsg;
-                       return -1;
-               }
-       }
-
-       _name = Glib::path_get_basename (newpath);
-       _path = newpath;
-
-       return 0;
-}
+               
+