X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=gtk2_ardour%2Feditor_audio_import.cc;h=a933197f7f3008ed30ce89266985ebc4f50c629e;hb=959a7909c1adca430a63f783fd16687242a7be3d;hp=abe6534b1b3bb4ff8ae2d1455cc4caefb18b1c97;hpb=96ca08b9257e4048294cd1804a65d4ae6cd88814;p=ardour.git diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc index abe6534b1b..a933197f7f 100644 --- a/gtk2_ardour/editor_audio_import.cc +++ b/gtk2_ardour/editor_audio_import.cc @@ -17,8 +17,14 @@ */ +#include +#include +#include +#include + #include #include +#include #include #include @@ -293,7 +299,7 @@ Editor::embed_sndfile (vector paths, bool split, bool multiple_fi linked_path += Glib::path_get_basename (path); if (link (path.c_str(), linked_path.c_str()) == 0) { - + /* there are many reasons why link(2) might have failed. but if it succeeds, we now have a link in the session sound dir that will protect against @@ -301,6 +307,21 @@ Editor::embed_sndfile (vector paths, bool split, bool multiple_fi */ path = linked_path; + + } else { + + /* one possible reason is that its already linked */ + + if (errno == EEXIST) { + struct stat sb; + + 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; + } + } + } + } /* note that we temporarily truncated _id at the colon */ @@ -380,7 +401,6 @@ Editor::embed_sndfile (vector paths, bool split, bool multiple_fi boost::shared_ptr s; if ((s = session->source_by_path_and_channel (path, n)) == 0) { - cerr << "source doesn't exist yet\n"; source = boost::dynamic_pointer_cast (SourceFactory::createReadable (DataType::AUDIO, *session, path, n, (mode == ImportAsTapeTrack ?