Remove beat entry from meter dialog (beats are not allowed in API), clean up some...
[ardour.git] / libs / ardour / utils.cc
index 6b5ea2cef664d5950f657ff423370306087ddefd..f98b24a4f2379636a399fe3ae295d7cfbf6d04c5 100644 (file)
@@ -125,6 +125,45 @@ legalize_for_path (string str)
 }
 #endif
 
+string bump_name_once(std::string name)
+{
+       string::size_type period;
+       string newname;
+
+       if ((period = name.find_last_of ('.')) == string::npos) {
+               newname  = name;
+               newname += ".1";
+       } else {
+               int isnumber = 1;
+               const char *last_element = name.c_str() + period + 1;
+               for (size_t i = 0; i < strlen(last_element); i++) {
+                       if (!isdigit(last_element[i])) {
+                               isnumber = 0;
+                               break;
+                       }
+               }
+
+               errno = 0;
+               long int version = strtol (name.c_str()+period+1, (char **)NULL, 10);
+
+               if (isnumber == 0 || errno != 0) {
+                       // last_element is not a number, or is too large
+                       newname  = name;
+                       newname += ".1";
+               } else {
+                       char buf[32];
+
+                       snprintf (buf, sizeof(buf), "%ld", version+1);
+               
+                       newname  = name.substr (0, period+1);
+                       newname += buf;
+               }
+       }
+
+       return newname;
+
+}
+
 ostream&
 operator<< (ostream& o, const BBT_Time& bbt)
 {
@@ -208,7 +247,7 @@ touch_file (ustring path)
 }
 
 ustring
-region_name_from_path (ustring path, bool strip_channels)
+region_name_from_path (ustring path, bool strip_channels, bool add_channel_suffix, uint32_t total, uint32_t this_one)
 {
        path = PBD::basename_nosuffix (path);
 
@@ -225,6 +264,17 @@ region_name_from_path (ustring path, bool strip_channels)
                }
        }
 
+       if (add_channel_suffix) {
+
+               path += '%';
+               
+               if (total > 2) {
+                       path += (char) ('a' + this_one);
+               } else {
+                       path += (char) (this_one == 0 ? 'L' : 'R');
+               }
+       }
+
        return path;
 }      
 
@@ -337,6 +387,8 @@ string_to_edit_mode (string str)
                return Splice;
        } else if (str == _("Slide Edit")) {
                return Slide;
+       } else if (str == _("Lock Edit")) {
+               return Lock;
        }
        fatal << string_compose (_("programming error: unknown edit mode string \"%1\""), str) << endmsg;
        /*NOTREACHED*/
@@ -350,6 +402,9 @@ edit_mode_to_string (EditMode mode)
        case Slide:
                return _("Slide Edit");
 
+       case Lock:
+               return _("Lock Edit");
+
        default:
        case Splice:
                return _("Splice Edit");