diff options
author | David Robillard <d@drobilla.net> | 2008-02-16 22:55:47 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-02-16 22:55:47 +0000 |
commit | 859e9106e72a7908fa093d946111d148223225a0 (patch) | |
tree | ec47825b5f5746bcbc5d321d40da7fc798f5c380 /libs/ardour/utils.cc | |
parent | 8aa9508c82f32efcf9c7c00e2c9e76268d4dddce (diff) |
Merge with 2.0-ongoing R3071.
git-svn-id: svn://localhost/ardour2/branches/3.0@3074 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/utils.cc')
-rw-r--r-- | libs/ardour/utils.cc | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc index cfd38c5099..99a6dbbc88 100644 --- a/libs/ardour/utils.cc +++ b/libs/ardour/utils.cc @@ -86,6 +86,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) { @@ -289,6 +328,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*/ @@ -302,6 +343,9 @@ edit_mode_to_string (EditMode mode) case Slide: return _("Slide Edit"); + case Lock: + return _("Lock Edit"); + default: case Splice: return _("Splice Edit"); |