From afd9fc30e51c41fb42b34d74d6043c2e0e3d1a13 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 30 Nov 2009 13:12:41 +0000 Subject: [PATCH] new rc config param, try-link-for-embed, controls whether we try hard linking for embedding files into a session git-svn-id: svn://localhost/ardour2/branches/3.0@6210 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor_audio_import.cc | 65 +++++++++++----------- libs/ardour/ardour/rc_configuration_vars.h | 1 + 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc index 35951c1da5..833d26168a 100644 --- a/gtk2_ardour/editor_audio_import.cc +++ b/gtk2_ardour/editor_audio_import.cc @@ -542,35 +542,38 @@ Editor::embed_sndfiles (vector paths, bool multifile, ustring path = *p; - /* lets see if we can link it into the session */ - - sys::path tmp = session->session_directory().sound_path() / Glib::path_get_basename(path); - linked_path = tmp.to_string(); - - path_to_use = linked_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 - unlinking of the original path. nice. - */ - - path = linked_path; - path_to_use = Glib::path_get_basename (path); - - } else { - - /* one possible reason is that its already linked */ - - if (errno == EEXIST) { - struct stat sb; + if (Config->get_try_link_for_embed()) { + + /* lets see if we can link it into the session */ + + sys::path tmp = session->session_directory().sound_path() / Glib::path_get_basename(path); + linked_path = tmp.to_string(); + + path_to_use = linked_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 + unlinking of the original path. nice. + */ + + path = linked_path; + path_to_use = Glib::path_get_basename (path); + + } else { - 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 (path); + /* 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; + path_to_use = Glib::path_get_basename (path); + } } } } @@ -651,9 +654,9 @@ Editor::embed_sndfiles (vector paths, bool multifile, if ((s = session->source_by_path_and_channel (path, n)) == 0) { source = boost::dynamic_pointer_cast ( - SourceFactory::createReadable (DataType::AUDIO, *session, - path_to_use, false, n, - (mode == ImportAsTapeTrack + SourceFactory::createReadable (DataType::AUDIO, *session, + path_to_use, n, + (mode == ImportAsTapeTrack ? Source::Destructive : Source::Flag (0)), true, true)); diff --git a/libs/ardour/ardour/rc_configuration_vars.h b/libs/ardour/ardour/rc_configuration_vars.h index bbf2656ed1..98f4e2d1b7 100644 --- a/libs/ardour/ardour/rc_configuration_vars.h +++ b/libs/ardour/ardour/rc_configuration_vars.h @@ -55,6 +55,7 @@ CONFIG_VARIABLE (float, audio_track_buffer_seconds, "track-buffer-seconds", 5.0) CONFIG_VARIABLE (float, midi_track_buffer_seconds, "midi-track-buffer-seconds", 1.0) CONFIG_VARIABLE (uint32_t, disk_choice_space_threshold, "disk-choice-space-threshold", 57600000) CONFIG_VARIABLE (bool, auto_analyse_audio, "auto-analyse-audio", false) +CONFIG_VARIABLE (bool, try_link_for_embed, "try-link-for-embed", true) /* OSC */ -- 2.30.2