another part of the fix for cleanup: when successfully using link(2) to embed a file...
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 25 Jun 2009 00:34:13 +0000 (00:34 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 25 Jun 2009 00:34:13 +0000 (00:34 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@5269 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor_audio_import.cc
libs/ardour/audiofilesource.cc

index fa946f90c9d6793ecebf63220b52757e62af6340..1b34d1e2a6033f7de3e67eef9d810869cd0274fc 100644 (file)
@@ -524,6 +524,7 @@ Editor::embed_sndfiles (vector<Glib::ustring> paths, bool multifile,
        string linked_path;
        SoundFileInfo finfo;
        int ret = 0;
+       Glib::ustring path_to_use;
 
        track_canvas->get_window()->set_cursor (Gdk::Cursor (Gdk::WATCH));
        gdk_flush ();
@@ -537,6 +538,8 @@ Editor::embed_sndfiles (vector<Glib::ustring> paths, bool multifile,
                linked_path = session->sound_dir();
                linked_path += '/';
                linked_path += Glib::path_get_basename (path);
+
+               path_to_use = path;
                
                if (link (path.c_str(), linked_path.c_str()) == 0) {
 
@@ -547,6 +550,7 @@ Editor::embed_sndfiles (vector<Glib::ustring> paths, bool multifile,
                        */
                        
                        path = linked_path;
+                       path_to_use = Glib::path_get_basename (linked_path);
 
                } else {
 
@@ -558,6 +562,7 @@ Editor::embed_sndfiles (vector<Glib::ustring> paths, bool multifile,
                                if (stat (linked_path.c_str(), &sb) == 0) {
                                        if (sb.st_nlink > 1) { // its a hard link, assume its the one we want
                                                path = linked_path;
+                                               path_to_use = Glib::path_get_basename (linked_path);
                                        }
                                }
                        }
@@ -638,7 +643,7 @@ Editor::embed_sndfiles (vector<Glib::ustring> paths, bool multifile,
                                if ((s = session->source_by_path_and_channel (path, n)) == 0) {
 
                                        source = boost::dynamic_pointer_cast<AudioFileSource> (SourceFactory::createReadable 
-                                                                                              (*session, path,  n,
+                                                                                              (*session, path_to_use,  n,
                                                                                                (mode == ImportAsTapeTrack ? 
                                                                                                 AudioFileSource::Destructive : 
                                                                                                 AudioFileSource::Flag (0)),
index ac5a6e7b8ca144375669d4d19656935127ceb4e1..b5069245134ade82162d68a6f36cc89403e1f93e 100644 (file)
@@ -154,7 +154,11 @@ AudioFileSource::init (ustring pathstr, bool must_exist)
        timeline_position = 0;
        _peaks_built = false;
 
-       if (!find (pathstr, must_exist, is_embedded(), file_is_new, _channel, _path, _name)) {
+       /* is_embedded() can't work yet, because our _path is not set */
+
+       bool embedded = determine_embeddedness (pathstr);
+
+       if (!find (pathstr, must_exist, embedded, file_is_new, _channel, _path, _name)) {
                throw non_existent_source ();
        }
 
@@ -568,7 +572,7 @@ AudioFileSource::find (ustring pathstr, bool must_exist, bool embedded,
                if (embedded) {
                        name = pathstr;
                } else {
-                       name = pathstr.substr (pathstr.find_last_of ('/') + 1);
+                       name = Glib::path_get_basename (pathstr);
                }
 
                if (!Glib::file_test (pathstr, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR)) {