mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-03 04:09:29 +01:00
fix up file renaming code a little bit
git-svn-id: svn://localhost/ardour2/branches/3.0@7460 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
6ef49a0b86
commit
7ab8dbc2fe
2 changed files with 12 additions and 10 deletions
|
|
@ -395,11 +395,11 @@ FileSource::set_source_name (const ustring& newname, bool destructive)
|
|||
error << string_compose (_("Programming error! %1 tried to rename a file over another file! It's safe to continue working, but please report this to the developers."), PROGRAM_NAME) << endmsg;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (::rename (oldpath.c_str(), newpath.c_str()) != 0) {
|
||||
error << string_compose (_("cannot rename audio file %1 to %2"), _name, newpath) << endmsg;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (::rename (oldpath.c_str(), newpath.c_str()) != 0) {
|
||||
error << string_compose (_("cannot rename file %1 to %2 (%3)"), oldpath, newpath, strerror(errno)) << endmsg;
|
||||
return -1;
|
||||
}
|
||||
|
||||
_name = Glib::path_get_basename (newpath);
|
||||
_path = newpath;
|
||||
|
|
|
|||
|
|
@ -2692,12 +2692,13 @@ Session::change_source_path_by_name (string path, string oldname, string newname
|
|||
|
||||
prefix = path.substr (0, dash);
|
||||
|
||||
path = dir;
|
||||
path += prefix;
|
||||
path += '-';
|
||||
path += new_legalized;
|
||||
path += ".wav"; /* XXX gag me with a spoon */
|
||||
|
||||
path = Glib::build_filename (dir, path);
|
||||
|
||||
} else {
|
||||
|
||||
/* non-destructive file sources have a name of the form:
|
||||
|
|
@ -2743,10 +2744,12 @@ Session::change_source_path_by_name (string path, string oldname, string newname
|
|||
|
||||
for (uint32_t cnt = 1; cnt <= limit; ++cnt) {
|
||||
|
||||
snprintf (buf, sizeof(buf), "%s%s-%u%s", dir.c_str(), newname.c_str(), cnt, suffix.c_str());
|
||||
snprintf (buf, sizeof(buf), "%s-%u%s", newname.c_str(), cnt, suffix.c_str());
|
||||
|
||||
if (!Glib::file_test (buf, Glib::FILE_TEST_EXISTS)) {
|
||||
path = buf;
|
||||
string p = Glib::build_filename (dir, buf);
|
||||
|
||||
if (!Glib::file_test (p, Glib::FILE_TEST_EXISTS)) {
|
||||
path = p;
|
||||
break;
|
||||
}
|
||||
path = "";
|
||||
|
|
@ -2755,7 +2758,6 @@ Session::change_source_path_by_name (string path, string oldname, string newname
|
|||
if (path == "") {
|
||||
error << "FATAL ERROR! Could not find a " << endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return path;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue