change builtin export format/preset search path to correct value; remove line of...
[ardour.git] / libs / ardour / export_profile_manager.cc
index 65b74103ae05da92efe7a056013339f26f8b1f03..ff11262109d58a7840f068aa6e5bdb96d532acb0 100644 (file)
@@ -65,17 +65,11 @@ ExportProfileManager::ExportProfileManager (Session & s, std::string xml_node_na
 
        export_config_dir = user_config_directory();
        export_config_dir /= "export";
-       search_path += export_config_dir;
-
-       search_path += ardour_search_path().add_subdirectory_to_paths("export");
 
-       sys::path sys_export = ardour_module_directory();
-       sys_export /= "export";
-
-       search_path += sys_export;
+       search_path += export_config_dir;
+       search_path += system_data_search_path().add_subdirectory_to_paths("export");
 
        info << string_compose (_("Searching for export formats in %1"), search_path.to_string()) << endmsg;
-       cerr << string_compose (_("Searching for export formats in %1"), search_path.to_string()) << endl;
 
        /* create export config directory if necessary */
 
@@ -181,10 +175,27 @@ ExportProfileManager::load_presets ()
        }
 }
 
+std::string
+ExportProfileManager::preset_filename (std::string const & preset_name)
+{
+       string safe_name = legalize_for_path (preset_name);
+       return export_config_dir.to_string() + "/" + safe_name + export_preset_suffix;
+}
+
+ExportProfileManager::PresetPtr
+ExportProfileManager::new_preset (string const & name)
+{
+       // Generate new ID and do regular save
+       string filename = preset_filename (name);
+       current_preset.reset (new ExportPreset (filename, session));
+       preset_list.push_back (current_preset);
+       return save_preset (name);
+}
+
 ExportProfileManager::PresetPtr
 ExportProfileManager::save_preset (string const & name)
 {
-       string filename = export_config_dir.to_string() + "/" + name + export_preset_suffix;
+       string filename = preset_filename (name);
 
        if (!current_preset) {
                current_preset.reset (new ExportPreset (filename, session));
@@ -519,6 +530,10 @@ ExportProfileManager::save_format_to_disk (FormatPtr format)
        string new_name = format->name();
        new_name += export_format_suffix;
 
+        /* make sure its legal for the filesystem */
+
+        new_name = legalize_for_path (new_name);
+
        sys::path new_path (export_config_dir);
        new_path /= new_name;
 
@@ -724,6 +739,8 @@ ExportProfileManager::get_warnings ()
 {
        boost::shared_ptr<Warnings> warnings (new Warnings ());
 
+       assert (!channel_configs.empty ());
+
        ChannelConfigStatePtr channel_config_state = channel_configs.front();
        TimespanStatePtr timespan_state = timespans.front();