add missing extra file
[ardour.git] / libs / ardour / export_filename.cc
index 3b8c27bc07d24c3433f9c2cc90f6c8327e718ccc..f7fe22c3b48c5a37b72435f55f2f6ad5305033bf 100644 (file)
 */
 
 #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"
 
@@ -45,6 +50,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),
@@ -101,15 +107,24 @@ ExportFilename::set_state (const XMLNode & node)
        folder = "";
 
        if ((prop = child->property ("relative"))) {
-               if (!prop->value().compare ("true")) {
+               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;
@@ -140,11 +155,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();
@@ -195,10 +208,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