From 3b32566d301c6786a53e08ae8035a32aa1fcc4ff Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Tue, 13 Nov 2007 06:40:50 +0000 Subject: [PATCH] Modify Session::path_from_region_name for portability git-svn-id: svn://localhost/ardour2/trunk@2637 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/session_state.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 78818211f7..877047d93a 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -1573,23 +1573,24 @@ Session::path_from_region_name (DataType type, string name, string identifier) char buf[PATH_MAX+1]; uint32_t n; SessionDirectory sdir(get_best_session_directory_for_new_source()); - string sound_dir = ((type == DataType::AUDIO) - ? sdir.sound_path().to_string() - : sdir.midi_path().to_string()); + sys::path source_dir = ((type == DataType::AUDIO) + ? sdir.sound_path() : sdir.midi_path()); string ext = ((type == DataType::AUDIO) ? ".wav" : ".mid"); for (n = 0; n < 999999; ++n) { if (identifier.length()) { - snprintf (buf, sizeof(buf), "%s/%s%s%" PRIu32 "%s", sound_dir.c_str(), name.c_str(), + snprintf (buf, sizeof(buf), "%s%s%" PRIu32 "%s", name.c_str(), identifier.c_str(), n, ext.c_str()); } else { - snprintf (buf, sizeof(buf), "%s/%s-%" PRIu32 "%s", sound_dir.c_str(), name.c_str(), + snprintf (buf, sizeof(buf), "%s-%" PRIu32 "%s", name.c_str(), n, ext.c_str()); } - if (!sys::exists (buf)) { - return buf; + sys::path source_path = source_dir / buf; + + if (!sys::exists (source_path)) { + return source_path.to_string(); } }