diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-05-19 03:03:28 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-05-19 03:03:28 +0000 |
commit | e258b2622a4386b405c2216d79b34887c3ed55bf (patch) | |
tree | c2abdacc5a31e9d572257050256c704b41fb46f5 /libs/ardour/utils.cc | |
parent | c25c7598c134af88bb85b5690aabc35472c77adf (diff) |
MIDI region forking, plus Playlist::regions_to_read() fix forward ported from 2.X. region forking requires a few cleanups
git-svn-id: svn://localhost/ardour2/branches/3.0@7118 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/utils.cc')
-rw-r--r-- | libs/ardour/utils.cc | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc index af90c935c9..2bfe16222d 100644 --- a/libs/ardour/utils.cc +++ b/libs/ardour/utils.cc @@ -72,17 +72,19 @@ legalize_for_path (ustring str) return legal; } -string bump_name_once(std::string name) +string +bump_name_once (const std::string& name, char delimiter) { - string::size_type period; + string::size_type delim; string newname; - if ((period = name.find_last_of ('.')) == string::npos) { + if ((delim = name.find_last_of (delimiter)) == string::npos) { newname = name; - newname += ".1"; + newname += delimiter; + newname += "1"; } else { int isnumber = 1; - const char *last_element = name.c_str() + period + 1; + const char *last_element = name.c_str() + delim + 1; for (size_t i = 0; i < strlen(last_element); i++) { if (!isdigit(last_element[i])) { isnumber = 0; @@ -91,18 +93,19 @@ string bump_name_once(std::string name) } errno = 0; - long int version = strtol (name.c_str()+period+1, (char **)NULL, 10); + long int version = strtol (name.c_str()+delim+1, (char **)NULL, 10); if (isnumber == 0 || errno != 0) { // last_element is not a number, or is too large newname = name; - newname += ".1"; + newname += delimiter; + newname += "1"; } else { char buf[32]; snprintf (buf, sizeof(buf), "%ld", version+1); - newname = name.substr (0, period+1); + newname = name.substr (0, delim+1); newname += buf; } } |