summaryrefslogtreecommitdiff
path: root/libs/ardour/template_utils.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2011-12-11 20:38:42 +0000
committerCarl Hetherington <carl@carlh.net>2011-12-11 20:38:42 +0000
commit73a91402cd0b12cf2cfe70f8fc4d4e4667fd259b (patch)
tree387106c75b4e1177306d3a80d76689808c07f68b /libs/ardour/template_utils.cc
parenta03f3229f44742b579fc0dabf7a2b364e1a9b96b (diff)
Save templates as directories with plugin state, if
there is any, and copy that state to sessions created from those templates. Should fix #4525. Breaks existing session templates, sorry; they can be fixed by moving the .template file into a new directory with the name of the template (minus the .template). git-svn-id: svn://localhost/ardour2/branches/3.0@10982 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/template_utils.cc')
-rw-r--r--libs/ardour/template_utils.cc30
1 files changed, 22 insertions, 8 deletions
diff --git a/libs/ardour/template_utils.cc b/libs/ardour/template_utils.cc
index aa0a583af4..825a24d3e1 100644
--- a/libs/ardour/template_utils.cc
+++ b/libs/ardour/template_utils.cc
@@ -1,6 +1,8 @@
#include <algorithm>
#include <cstring>
+#include <glibmm.h>
+
#include "pbd/filesystem.h"
#include "pbd/basename.h"
#include "pbd/pathscanner.h"
@@ -66,11 +68,23 @@ user_route_template_directory ()
static bool
template_filter (const string &str, void */*arg*/)
{
- cerr << "Checking into " << str << " using " << template_suffix << endl;
- return (str.length() > strlen(template_suffix) &&
- str.find (template_suffix) == (str.length() - strlen (template_suffix)));
+ if (!Glib::file_test (str, Glib::FILE_TEST_IS_DIR)) {
+ return false;
+ }
+
+ return true;
+}
+
+string
+session_template_dir_to_file (string const & dir)
+{
+ sys::path dir_path = dir;
+ sys::path file_path = dir;
+ file_path /= dir_path.leaf() + template_suffix;
+ return file_path.to_string ();
}
+
void
find_session_templates (vector<TemplateInfo>& template_names)
{
@@ -79,7 +93,7 @@ find_session_templates (vector<TemplateInfo>& template_names)
SearchPath spath (system_template_directory());
spath += user_template_directory ();
- templates = scanner (spath.to_string(), template_filter, 0, false, true);
+ templates = scanner (spath.to_string(), template_filter, 0, true, true);
if (!templates) {
cerr << "Found nothing along " << spath.to_string() << endl;
@@ -89,18 +103,18 @@ find_session_templates (vector<TemplateInfo>& template_names)
cerr << "Found " << templates->size() << " along " << spath.to_string() << endl;
for (vector<string*>::iterator i = templates->begin(); i != templates->end(); ++i) {
- string fullpath = *(*i);
+ string file = session_template_dir_to_file (**i);
XMLTree tree;
- if (!tree.read (fullpath.c_str())) {
+ if (!tree.read (file.c_str())) {
continue;
}
TemplateInfo rti;
- rti.name = basename_nosuffix (fullpath);
- rti.path = fullpath;
+ rti.name = basename_nosuffix (**i);
+ rti.path = **i;
template_names.push_back (rti);
}