*/
-#include <ardour/export_profile_manager.h>
-
#include <cassert>
#include <stdexcept>
#include <glibmm/fileutils.h>
-#include <pbd/enumwriter.h>
-#include <pbd/xml++.h>
-#include <pbd/convert.h>
-
-#include <ardour/export_failed.h>
-#include <ardour/export_file_io.h>
-#include <ardour/export_format_specification.h>
-#include <ardour/export_timespan.h>
-#include <ardour/export_channel_configuration.h>
-#include <ardour/export_filename.h>
-#include <ardour/export_preset.h>
-#include <ardour/export_handler.h>
-#include <ardour/filename_extensions.h>
-#include <ardour/session.h>
+#include "pbd/enumwriter.h"
+#include "pbd/xml++.h"
+#include "pbd/convert.h"
+
+#include "ardour/export_profile_manager.h"
+#include "ardour/export_file_io.h"
+#include "ardour/export_format_specification.h"
+#include "ardour/export_timespan.h"
+#include "ardour/export_channel_configuration.h"
+#include "ardour/export_filename.h"
+#include "ardour/export_preset.h"
+#include "ardour/export_handler.h"
+#include "ardour/filename_extensions.h"
+#include "ardour/session.h"
#include "i18n.h"
+using namespace std;
+using namespace Glib;
using namespace PBD;
namespace ARDOUR
/* 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;
-
- path = system_config_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");;
/* create export config directory if necessary */
ExportProfileManager::~ExportProfileManager ()
{
+ if (single_range_mode) { return; }
+
XMLNode * instant_xml (new XMLNode ("ExportProfile"));
serialize_profile (*instant_xml);
session.add_instant_xml (*instant_xml, false);
ExportProfileManager::PresetPtr
ExportProfileManager::save_preset (string const & name)
{
+ string filename = export_config_dir.to_string() + "/" + name + export_preset_suffix;
+
if (!current_preset) {
- string filename = export_config_dir.to_string() + "/" + name + export_preset_suffix;
current_preset.reset (new ExportPreset (filename, session));
preset_list.push_back (current_preset);
}
current_preset->set_global_state (*global_preset);
current_preset->set_local_state (*local_preset);
- current_preset->save();
+ current_preset->save (filename);
return current_preset;
}
ExportProfileManager::load_preset_from_disk (PBD::sys::path const & path)
{
PresetPtr preset (new ExportPreset (path.to_string(), session));
- preset_list.push_back (preset);
- /* Handle id to filename mapping */
+ /* Handle id to filename mapping and don't add duplicates to list */
FilePair pair (preset->id(), path);
- preset_file_map.insert (pair);
+ if (preset_file_map.insert (pair).second) {
+ preset_list.push_back (preset);
+ }
}
bool
/* 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 */
{
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 ();
}
/* Check format and maximum channel count */
if (!format || !format->type()) {
warnings->errors.push_back (_("No format selected!"));
+ } else if (!channel_config->get_n_chans()) {
+ warnings->errors.push_back (_("All channels are empty!"));
} else if (!ExportFileFactory::check (format, channel_config->get_n_chans())) {
warnings->errors.push_back (_("One or more of the selected formats is not compatible with this system!"));
} else if (format->channel_limit() < channel_config->get_n_chans()) {