forward port 2.X changes up to and including rev 6909
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 17 Aug 2010 13:10:42 +0000 (13:10 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 17 Aug 2010 13:10:42 +0000 (13:10 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@7639 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/automatable.cc
libs/ardour/file_source.cc
libs/ardour/find_session.cc
libs/ardour/import.cc
libs/ardour/midi_diskstream.cc
libs/ardour/plugin_manager.cc
libs/ardour/session_state.cc
libs/ardour/utils.cc

index d6379eb38e55fb3f349e04606769a55084101290..5ae4e96b4e1f87436e53a0356ba9ed350e6d22b6 100644 (file)
@@ -22,6 +22,9 @@
 #include <inttypes.h>
 #include <cstdio>
 #include <errno.h>
+
+#include <glibmm/miscutils.h>
+
 #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();
index 512d37a10b5745195131fa62c6c0a3bce80d3237..6a72359a962106af194e4eecfc33d58ce1e11416 100644 (file)
@@ -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<ustring>::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));
index 90a54b1390d3354d5156518611977ce7223a05f7..c635b86545ad442c457d76d6290f0c0e9fa76f91 100644 (file)
@@ -5,6 +5,8 @@
 #include <climits>
 #include <cerrno>
 
+#include <glibmm/miscutils.h>
+
 #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) {
 
index 156186dbe4251a57dfcbdb05832e529978fbbc67..c3352a61272b18a8c02bb365bede5cf903e36c64 100644 (file)
@@ -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);
        }
 
index 3151869fc30438c8ebec21913ac53e61980de511..9b8077774d72e19df4dac327d59b0d2aa0f193e5 100644 (file)
@@ -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);
index 5597fac9e8802beba71e86644b161ee63a128cbd..91c4d715d5f80f4625d1fc32dcebd9ff364fe20d 100644 (file)
@@ -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;
index a2dc6ced68f64bded95a7d66586cce08f8baa899..31282a210f761766543e1e7a0cfbf934c610899c 100644 (file)
@@ -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<string>& 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<string>& 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 */
 
index 6f8586648d6063548baae92e337151108050d51d..a7d5b960f82c2beb31fe05d7fca3a2ab8022ac1e 100644 (file)
@@ -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);
        }