allow to get custom/product/version independent cach dir
[ardour.git] / libs / ardour / export_filename.cc
index 8186982384e130f80907bfe733370fff57b2b692..177d515028b013a9ad6d778e7a9a69b495acde9c 100644 (file)
@@ -26,6 +26,7 @@
 #include "pbd/xml++.h"
 #include "pbd/convert.h"
 #include "pbd/enumwriter.h"
+#include "pbd/localtime_r.h"
 
 #include "ardour/libardour_visibility.h"
 #include "ardour/session.h"
@@ -36,7 +37,7 @@
 #include "ardour/export_timespan.h"
 #include "ardour/utils.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace PBD;
 using namespace Glib;
@@ -62,7 +63,7 @@ ExportFilename::ExportFilename (Session & session) :
 {
        time_t rawtime;
        std::time (&rawtime);
-       time_struct = localtime (&rawtime);
+       localtime_r (&rawtime, &time_struct);
 
        folder = session.session_directory().export_path();
 
@@ -90,6 +91,7 @@ ExportFilename::get_state ()
 
        add_field (node, "label", include_label, label);
        add_field (node, "session", include_session);
+       add_field (node, "timespan", include_timespan);
        add_field (node, "revision", include_revision);
        add_field (node, "time", include_time, enum_2_string (time_format));
        add_field (node, "date", include_date, enum_2_string (date_format));
@@ -105,7 +107,7 @@ int
 ExportFilename::set_state (const XMLNode & node)
 {
        XMLNode * child;
-       XMLProperty * prop;
+       XMLProperty const * prop;
        FieldPair pair;
 
        child = node.child ("Folder");
@@ -140,6 +142,9 @@ ExportFilename::set_state (const XMLNode & node)
        pair = get_field (node, "session");
        include_session = pair.first;
 
+       pair = get_field (node, "timespan");
+       include_timespan = pair.first;
+
        pair = get_field (node, "revision");
        include_revision = pair.first;
 
@@ -335,7 +340,7 @@ string
 ExportFilename::get_formatted_time (string const & format) const
 {
        char buffer [80];
-       strftime (buffer, 80, format.c_str(), time_struct);
+       strftime (buffer, 80, format.c_str(), &time_struct);
 
        string return_value (buffer);
        return return_value;
@@ -367,7 +372,7 @@ ExportFilename::get_field (XMLNode const & node, string const & name)
        XMLNodeList children = node.children();
 
        for (XMLNodeList::iterator it = children.begin(); it != children.end(); ++it) {
-               XMLProperty * prop = (*it)->property ("name");
+               XMLProperty const * prop = (*it)->property ("name");
                if (prop && !prop->value().compare (name)) {
 
                        prop = (*it)->property ("enabled");