*/
#include <string>
-#include "ardour/export_filename.h"
+
+#include <glibmm/miscutils.h>
+#include <glibmm/fileutils.h>
#include "pbd/xml++.h"
#include "pbd/convert.h"
#include "pbd/enumwriter.h"
+#include "ardour/libardour_visibility.h"
#include "ardour/session.h"
#include "ardour/session_directory.h"
-#include "ardour/export_timespan.h"
+#include "ardour/export_filename.h"
#include "ardour/export_format_specification.h"
#include "ardour/export_channel_configuration.h"
+#include "ardour/export_timespan.h"
+#include "ardour/utils.h"
#include "i18n.h"
include_session (false),
include_revision (false),
include_channel_config (false),
+ include_format_name (false),
include_channel (false),
include_timespan (true), // Include timespan name always
include_time (false),
std::time (&rawtime);
time_struct = localtime (&rawtime);
- folder = session.session_directory().export_path().to_string();
+ folder = session.session_directory().export_path();
XMLNode * instant_node = session.instant_xml ("ExportFilename");
if (instant_node) {
folder = "";
if ((prop = child->property ("relative"))) {
- if (!prop->value().compare ("true")) {
- folder = session.session_directory().root_path().to_string();
+ if (string_is_affirmative (prop->value())) {
+ folder = session.session_directory().root_path();
}
}
if ((prop = child->property ("path"))) {
- folder += prop->value();
+ std::string tmp;
+ tmp = Glib::build_filename (folder, prop->value());
+ if (!Glib::file_test (tmp, Glib::FILE_TEST_EXISTS)) {
+ warning << string_compose (_("Existing export folder for this session (%1) does not exist - ignored"), tmp) << endmsg;
+ } else {
+ folder = tmp;
+ }
+ }
+
+ if (folder.empty()) {
+ folder = session.session_directory().export_path();
}
-
pair = get_field (node, "label");
include_label = pair.first;
string
ExportFilename::get_path (ExportFormatSpecPtr format) const
{
- string path = folder;
+ string path;
bool filename_empty = true;
- path += "/";
-
if (include_session) {
path += filename_empty ? "" : "_";
path += session.name();
filename_empty = false;
}
+ if (include_format_name) {
+ path += filename_empty ? "" : "_";
+ path += format->name();
+ filename_empty = false;
+ }
+
path += ".";
path += format->extension ();
- return path;
+ path = legalize_for_universal_path (path);
+
+ return Glib::build_filename (folder, path);
}
string
{
FieldPair pair;
- string session_dir = session.session_directory().root_path().to_string();
+ string session_dir = session.session_directory().root_path();
string::size_type session_dir_len = session_dir.length();
string folder_beginning = folder.substr (0, session_dir_len);