From c13b74cd7667f91a741decbde2a40fb1fdb4c32d Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sun, 22 Jun 2014 21:58:07 -0400 Subject: [PATCH] when exporting regions, use ::legalize_for_path() on the playlist name so that filenames are legal. Also, use Glib::build_filename() rather than hardcoding / as the separator. How did this escape the search for this error? --- libs/ardour/session.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 95d319b4d8..2063891a72 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -4129,7 +4129,6 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end, boost::shared_ptr playlist; boost::shared_ptr fsource; uint32_t x; - char buf[PATH_MAX+1]; ChanCount diskstream_channels (track.n_channels()); framepos_t position; framecnt_t this_chunk; @@ -4142,6 +4141,8 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end, bool need_block_size_reset = false; string ext; ChanCount const max_proc = track.max_processor_streams (); + string legal_playlist_name; + string possible_path; if (end <= start) { error << string_compose (_("Cannot write a range where end <= start (e.g. %1 <= %2)"), @@ -4177,13 +4178,15 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end, goto out; } + legal_playlist_name = legalize_for_path (playlist->name()); + ext = native_header_format_extension (config.get_native_file_header_format(), DataType::AUDIO); for (uint32_t chan_n = 0; chan_n < diskstream_channels.n_audio(); ++chan_n) { for (x = 0; x < 99999; ++x) { - snprintf (buf, sizeof(buf), "%s/%s-%d-bounce-%" PRIu32 "%s", sound_dir.c_str(), playlist->name().c_str(), chan_n, x+1, ext.c_str()); - if (!Glib::file_test (buf, Glib::FILE_TEST_EXISTS)) { + possible_path = Glib::build_filename (sound_dir, string_compose ("%1-%2-bounce-%3%4", legal_playlist_name.c_str(), chan_n, x+1, ext.c_str())); + if (!Glib::file_test (possible_path, Glib::FILE_TEST_EXISTS)) { break; } } @@ -4195,11 +4198,11 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end, try { fsource = boost::dynamic_pointer_cast ( - SourceFactory::createWritable (DataType::AUDIO, *this, buf, false, frame_rate())); + SourceFactory::createWritable (DataType::AUDIO, *this, possible_path, false, frame_rate())); } catch (failed_constructor& err) { - error << string_compose (_("cannot create new audio file \"%1\" for %2"), buf, track.name()) << endmsg; + error << string_compose (_("cannot create new audio file \"%1\" for %2"), possible_path, track.name()) << endmsg; goto out; }