summaryrefslogtreecommitdiff
path: root/libs/ardour/export_profile_manager.cc
diff options
context:
space:
mode:
authorSakari Bergen <sakari.bergen@beatwaves.net>2008-10-16 14:18:55 +0000
committerSakari Bergen <sakari.bergen@beatwaves.net>2008-10-16 14:18:55 +0000
commit5fa6ed1966d68b10041d7c563ef214ef33be0e88 (patch)
tree1179480d347db31928406355657ce6ca94772ae6 /libs/ardour/export_profile_manager.cc
parent3d47c31d8f8b6107d5479442d6d2bb60ab00dadd (diff)
Fix handling of format profiles in system config dirs. (Some profiles could now be shipped with Ardour)
git-svn-id: svn://localhost/ardour2/branches/3.0@3976 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/export_profile_manager.cc')
-rw-r--r--libs/ardour/export_profile_manager.cc44
1 files changed, 26 insertions, 18 deletions
diff --git a/libs/ardour/export_profile_manager.cc b/libs/ardour/export_profile_manager.cc
index 1d1c66665f..b5d85fcfa2 100644
--- a/libs/ardour/export_profile_manager.cc
+++ b/libs/ardour/export_profile_manager.cc
@@ -60,19 +60,14 @@ ExportProfileManager::ExportProfileManager (Session & s) :
/* Initialize path variables */
- sys::path path;
-
export_config_dir = user_config_directory();
export_config_dir /= "export";
search_path += export_config_dir;
- path = ardour_search_path().to_string();
- path /= "export";
- search_path += path;
+ search_path += ardour_search_path().add_subdirectory_to_paths("export");
+ search_path += system_config_search_path().add_subdirectory_to_paths("export");;
- path = system_config_search_path().to_string();
- path /= "export";
- search_path += path;
+ std::cout << "search_path: " << search_path.to_string () << std::endl;
/* create export config directory if necessary */
@@ -480,19 +475,31 @@ ExportProfileManager::save_format_to_disk (FormatPtr format)
/* Check if format is on disk already */
FileMap::iterator it;
if ((it = format_file_map.find (format->id())) != format_file_map.end()) {
- /* Update data */
- {
- XMLTree tree (it->second.to_string());
+
+ /* Check if config is not in user config dir */
+ if (it->second.branch_path().to_string().compare (export_config_dir.to_string())) {
+
+ /* Write new file */
+
+ XMLTree tree (new_path.to_string());
tree.set_root (&format->get_state());
tree.write();
- }
- /* Rename if necessary */
+ } else {
+
+ /* Update file and rename if necessary */
- if (new_name.compare (it->second.leaf())) {
- sys::rename (it->second, new_path);
+ XMLTree tree (it->second.to_string());
+ tree.set_root (&format->get_state());
+ tree.write();
+
+ if (new_name.compare (it->second.leaf())) {
+ sys::rename (it->second, new_path);
+ }
}
+ it->second = new_path;
+
} else {
/* Write new file */
@@ -612,12 +619,13 @@ ExportProfileManager::load_format_from_disk (PBD::sys::path const & path)
{
XMLTree const tree (path.to_string());
FormatPtr format = handler->add_format (*tree.root());
- format_list->push_back (format);
- /* Handle id to filename mapping */
+ /* Handle id to filename mapping and don't add duplicates to list */
FilePair pair (format->id(), path);
- format_file_map.insert (pair);
+ if (format_file_map.insert (pair).second) {
+ format_list->push_back (format);
+ }
FormatListChanged ();
}