summaryrefslogtreecommitdiff
path: root/libs/ardour/import.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-11-09 22:18:52 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-11-09 22:18:52 +0000
commit84ddf22169c3aee19d3420b20c0e2f1b9bbdf02f (patch)
treebd0ea7e57c143d4d88abc957bafc3941a343d8a4 /libs/ardour/import.cc
parent2575a3907b665e0ff3f151221e5c753c84d512ee (diff)
handle multiple imports of the same file better (via better source naming); make session properties editor pretty much work for search paths
git-svn-id: svn://localhost/ardour2/branches/3.0@7989 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/import.cc')
-rw-r--r--libs/ardour/import.cc40
1 files changed, 26 insertions, 14 deletions
diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc
index 4fc546ebd5..3dd2a99ee1 100644
--- a/libs/ardour/import.cc
+++ b/libs/ardour/import.cc
@@ -121,40 +121,52 @@ get_non_existent_filename (HeaderFormat hf, DataType type, const bool allow_repl
{
char buf[PATH_MAX+1];
bool goodfile = false;
- string base(basename);
+ string base = basename;
string ext = native_header_format_extension (hf, type);
+ uint32_t cnt = 1;
do {
if (type == DataType::AUDIO && channels == 2) {
if (channel == 0) {
- snprintf (buf, sizeof(buf), "%s-L%s", base.c_str(), ext.c_str());
+ if (cnt == 1) {
+ snprintf (buf, sizeof(buf), "%s-L%s", base.c_str(), ext.c_str());
+ } else {
+ snprintf (buf, sizeof(buf), "%s-%d-L%s", base.c_str(), cnt, ext.c_str());
+ }
} else {
- snprintf (buf, sizeof(buf), "%s-R%s", base.c_str(), ext.c_str());
+ if (cnt == 1) {
+ snprintf (buf, sizeof(buf), "%s-R%s", base.c_str(), ext.c_str());
+ } else {
+ snprintf (buf, sizeof(buf), "%s-%d-R%s", base.c_str(), cnt, ext.c_str());
+ }
}
} else if (channels > 1) {
- snprintf (buf, sizeof(buf), "%s-c%d%s", base.c_str(), channel, ext.c_str());
+ if (cnt == 1) {
+ snprintf (buf, sizeof(buf), "%s-c%d%s", base.c_str(), channel, ext.c_str());
+ } else {
+ snprintf (buf, sizeof(buf), "%s-%d-c%d%s", base.c_str(), cnt, channel, ext.c_str());
+ }
} else {
- snprintf (buf, sizeof(buf), "%s%s", base.c_str(), ext.c_str());
+ if (cnt == 1) {
+ snprintf (buf, sizeof(buf), "%s%s", base.c_str(), ext.c_str());
+ } else {
+ snprintf (buf, sizeof(buf), "%s-%d%s", base.c_str(), cnt, ext.c_str());
+ }
}
-
string tempname = destdir + "/" + buf;
+
if (!allow_replacing && Glib::file_test (tempname, Glib::FILE_TEST_EXISTS)) {
-
- /* if the file already exists, we must come up with
- * a new name for it. for now we just keep appending
- * _ to basename
- */
-
- base += "_";
+
+ cnt++;
} else {
goodfile = true;
}
- } while ( !goodfile);
+ } while (!goodfile);
return buf;
}