From 5fa6ed1966d68b10041d7c563ef214ef33be0e88 Mon Sep 17 00:00:00 2001 From: Sakari Bergen Date: Thu, 16 Oct 2008 14:18:55 +0000 Subject: 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 --- libs/ardour/export_profile_manager.cc | 44 +++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 18 deletions(-) (limited to 'libs') 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 (); } -- cgit v1.2.3