visualize port connections in mixer/processor when in < out
[ardour.git] / libs / ardour / export_filename.cc
index d5309bd535d46a611a70b35e0f69b4933e693ded..9e126ed08786e7dbd01c305be9c17c5e80159f80 100644 (file)
@@ -21,6 +21,9 @@
 #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"
@@ -30,7 +33,7 @@
 #include "ardour/export_timespan.h"
 #include "ardour/export_format_specification.h"
 #include "ardour/export_channel_configuration.h"
-#include "ardour/export_failed.h"
+#include "ardour/utils.h"
 
 #include "i18n.h"
 
@@ -46,6 +49,7 @@ ExportFilename::ExportFilename (Session & session) :
   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),
@@ -57,7 +61,7 @@ ExportFilename::ExportFilename (Session & session) :
        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) {
@@ -102,15 +106,24 @@ ExportFilename::set_state (const XMLNode & 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;
@@ -141,11 +154,9 @@ ExportFilename::set_state (const XMLNode & node)
 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();
@@ -196,10 +207,18 @@ ExportFilename::get_path (ExportFormatSpecPtr format) const
                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
@@ -346,7 +365,7 @@ ExportFilename::analyse_folder ()
 {
        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);