summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2007-04-06 02:48:29 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2007-04-06 02:48:29 +0000
commit0eafb1f3005d0ddf9f8ce8c6bde30f0ac641aa61 (patch)
tree726910858c6fc680030f452ef57dd55be3cf444b
parent8aab3489da7ce4edc6f2bd293420ced9c874e640 (diff)
fix crashes when handling files with ":" in their paths. Cost: cannot load old sessions with non-mono embedded files anymore
git-svn-id: svn://localhost/ardour2/trunk@1672 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/editor_audio_import.cc22
1 files changed, 21 insertions, 1 deletions
diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc
index df737429bd..2f63de340e 100644
--- a/gtk2_ardour/editor_audio_import.cc
+++ b/gtk2_ardour/editor_audio_import.cc
@@ -17,6 +17,11 @@
*/
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <unistd.h>
+
#include <pbd/pthread_utils.h>
#include <pbd/basename.h>
#include <pbd/shortpath.h>
@@ -294,7 +299,7 @@ Editor::embed_sndfile (vector<Glib::ustring> 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
@@ -302,6 +307,21 @@ Editor::embed_sndfile (vector<Glib::ustring> 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 */