From a5e74a774c6e1b39672392e26ee48385c4ac0034 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 17 Aug 2010 13:10:42 +0000 Subject: [PATCH] forward port 2.X changes up to and including rev 6909 git-svn-id: svn://localhost/ardour2/branches/3.0@7639 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/automatable.cc | 5 ++++- libs/ardour/file_source.cc | 18 ++++-------------- libs/ardour/find_session.cc | 14 ++++++-------- libs/ardour/import.cc | 4 ++-- libs/ardour/midi_diskstream.cc | 2 +- libs/ardour/plugin_manager.cc | 2 +- libs/ardour/session_state.cc | 18 ++++++++---------- libs/ardour/utils.cc | 2 +- 8 files changed, 27 insertions(+), 38 deletions(-) diff --git a/libs/ardour/automatable.cc b/libs/ardour/automatable.cc index d6379eb38e..5ae4e96b4e 100644 --- a/libs/ardour/automatable.cc +++ b/libs/ardour/automatable.cc @@ -22,6 +22,9 @@ #include #include #include + +#include + #include "pbd/error.h" #include "pbd/enumwriter.h" @@ -98,7 +101,7 @@ Automatable::load_automation (const string& path) { string fullpath; - if (path[0] == '/') { // legacy + if (Glib::path_is_absolute (path)) { // legacy fullpath = path; } else { fullpath = _a_session.automation_dir(); diff --git a/libs/ardour/file_source.cc b/libs/ardour/file_source.cc index 512d37a10b..6a72359a96 100644 --- a/libs/ardour/file_source.cc +++ b/libs/ardour/file_source.cc @@ -215,7 +215,7 @@ FileSource::find (DataType type, const ustring& path, bool must_exist, isnew = false; - if (pathstr[0] != '/') { + if (!Glib::path_is_absolute (pathstr)) { /* non-absolute pathname: find pathstr in search path */ @@ -234,12 +234,8 @@ FileSource::find (DataType type, const ustring& path, bool must_exist, cnt = 0; for (vector::iterator i = dirs.begin(); i != dirs.end(); ++i) { - fullpath = *i; - if (fullpath[fullpath.length()-1] != '/') { - fullpath += '/'; - } - - fullpath += pathstr; + + fullpath = Glib::build_filename (*i, pathstr); /* i (paul) made a nasty design error by using ':' as a special character in Ardour 0.99 .. this hack tries to make things sort of work. @@ -263,13 +259,7 @@ FileSource::find (DataType type, const ustring& path, bool must_exist, */ ustring shorter = pathstr.substr (0, pos); - fullpath = *i; - - if (fullpath[fullpath.length()-1] != '/') { - fullpath += '/'; - } - - fullpath += shorter; + fullpath = Glib::build_filename (*i, shorter); if (Glib::file_test (pathstr, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR)) { chan = atoi (pathstr.substr (pos+1)); diff --git a/libs/ardour/find_session.cc b/libs/ardour/find_session.cc index 90a54b1390..c635b86545 100644 --- a/libs/ardour/find_session.cc +++ b/libs/ardour/find_session.cc @@ -5,6 +5,8 @@ #include #include +#include + #include "pbd/compose.h" #include "pbd/error.h" @@ -53,17 +55,13 @@ ARDOUR::find_session (string str, string& path, string& snapshot, bool& isnew) if (S_ISDIR (statbuf.st_mode)) { - string::size_type slash = str.find_last_of ('/'); + string::size_type slash = str.find_last_of (G_DIR_SEPARATOR); if (slash == string::npos) { /* a subdirectory of cwd, so statefile should be ... */ - string tmp; - tmp = str; - tmp += '/'; - tmp += str; - tmp += statefile_suffix; + string tmp = Glib::build_filename (str, str+statefile_suffix); /* is it there ? */ @@ -90,7 +88,7 @@ ARDOUR::find_session (string str, string& path, string& snapshot, bool& isnew) } else if (S_ISREG (statbuf.st_mode)) { - string::size_type slash = str.find_last_of ('/'); + string::size_type slash = str.find_last_of (G_DIR_SEPARATOR); string::size_type suffix; /* remove the suffix */ @@ -148,7 +146,7 @@ ARDOUR::find_session (string str, string& path, string& snapshot, bool& isnew) as "dirname" does. */ - string::size_type slash = str.find_last_of ('/'); + string::size_type slash = str.find_last_of (G_DIR_SEPARATOR); if (slash == string::npos) { diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc index 156186dbe4..c3352a6127 100644 --- a/libs/ardour/import.cc +++ b/libs/ardour/import.cc @@ -174,8 +174,8 @@ get_paths_for_new_sources (HeaderFormat hf, const bool allow_replacing, const st std::string filepath = (type == DataType::MIDI) ? sdir.midi_path().to_string() : sdir.sound_path().to_string(); - filepath += '/'; - filepath += get_non_existent_filename (hf, type, allow_replacing, filepath, basename, n, channels); + filepath = Glib::build_filename (filepath, + get_non_existent_filename (hf, type, allow_replacing, filepath, basename, n, channels)); new_paths.push_back (filepath); } diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc index 3151869fc3..9b8077774d 100644 --- a/libs/ardour/midi_diskstream.cc +++ b/libs/ardour/midi_diskstream.cc @@ -514,7 +514,7 @@ MidiDiskstream::process (nframes_t transport_frame, nframes_t nframes, bool can_ adjust_capture_position = 0; - if (nominally_recording || (_session.get_record_enabled() && _session.config.get_punch_in())) { + if (nominally_recording || (re && was_recording && _session.get_record_enabled() && _session.config.get_punch_in())) { OverlapType ot = coverage (first_recordable_frame, last_recordable_frame, transport_frame, transport_frame + nframes); calculate_record_range(ot, transport_frame, nframes, rec_nframes, rec_offset); diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc index 5597fac9e8..91c4d715d5 100644 --- a/libs/ardour/plugin_manager.cc +++ b/libs/ardour/plugin_manager.cc @@ -201,7 +201,7 @@ PluginManager::ladspa_refresh () case ':' : case '\0': continue; - case '/' : + case G_DIR_SEPARATOR : if (ladspa_path[found + strlen(standard_paths[i]) + 1] == ':' || ladspa_path[found + strlen(standard_paths[i]) + 1] == '\0') { continue; diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index a2dc6ced68..31282a210f 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -145,7 +145,7 @@ Session::first_stage_init (string fullpath, string snapshot_name) _path = string(buf); if (_path[_path.length()-1] != '/') { - _path += '/'; + _path += G_DIR_SEPARATOR; } if (Glib::file_test (_path, Glib::FILE_TEST_EXISTS) && ::access (_path.c_str(), W_OK)) { @@ -2225,7 +2225,7 @@ remove_end(string* state) string statename(*state); string::size_type start,end; - if ((start = statename.find_last_of ('/')) != string::npos) { + if ((start = statename.find_last_of (G_DIR_SEPARATOR)) != string::npos) { statename = statename.substr (start+1); } @@ -2398,7 +2398,7 @@ Session::find_all_sources (string path, set& result) continue; } - if (prop->value()[0] == '/') { + if (Glib::path_is_absolute (prop->value())) { /* external file, ignore */ continue; } @@ -2427,7 +2427,7 @@ Session::find_all_sources_across_snapshots (set& result, bool exclude_th ripped = _path; - if (ripped[ripped.length()-1] == '/') { + if (ripped[ripped.length()-1] == G_DIR_SEPARATOR) { ripped = ripped.substr (0, ripped.length() - 1); } @@ -2634,18 +2634,16 @@ Session::cleanup_sources (CleanupReport& rep) newpath = Glib::path_get_dirname (newpath); // "session-dir" } - newpath += '/'; - newpath += dead_sound_dir_name; + newpath = Glib::build_filename (newpath, dead_sound_dir_name); if (g_mkdir_with_parents (newpath.c_str(), 0755) < 0) { error << string_compose(_("Session: cannot create session peakfile folder \"%1\" (%2)"), newpath, strerror (errno)) << endmsg; return -1; } - newpath += '/'; - newpath += Glib::path_get_basename ((*x)); - - if (access (newpath.c_str(), F_OK) == 0) { + newpath = Glib::build_filename (newpath, Glib::path_get_basename ((*x))); + + if (Glib::file_test (newpath, Glib::FILE_TEST_EXISTS)) { /* the new path already exists, try versioning */ diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc index 6f8586648d..a7d5b960f8 100644 --- a/libs/ardour/utils.cc +++ b/libs/ardour/utils.cc @@ -205,7 +205,7 @@ path_is_paired (ustring path, ustring& pair_base) /* remove any leading path */ - if ((pos = path.find_last_of ('/')) != string::npos) { + if ((pos = path.find_last_of (G_DIR_SEPARATOR)) != string::npos) { path = path.substr(pos+1); }