replace characters that would make an export filename illegal on any/all filesystems...
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 20 Dec 2012 13:08:50 +0000 (13:08 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 20 Dec 2012 13:08:50 +0000 (13:08 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@13689 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/utils.h
libs/ardour/export_filename.cc
libs/ardour/utils.cc

index 7a09f5e209b2933d93e195a3183e0ea5df20d52f..5e4cc3bdc40f38d041742fc1904f605c111d0ada 100644 (file)
@@ -39,6 +39,7 @@
 class XMLNode;
 
 std::string legalize_for_path (const std::string& str);
+std::string legalize_for_universal_path (const std::string& str);
 std::string legalize_for_path_2X (const std::string& str);
 XMLNode* find_named_node (const XMLNode& node, std::string name);
 std::string bool_as_string (bool);
index d00b0147a7bcd4bd7833947c34b34ada69cb73fa..a5b0a07a60a599d15202b43e3ff8c0f6ff953200 100644 (file)
@@ -33,6 +33,7 @@
 #include "ardour/export_timespan.h"
 #include "ardour/export_format_specification.h"
 #include "ardour/export_channel_configuration.h"
+#include "ardour/utils.h"
 
 #include "i18n.h"
 
@@ -208,6 +209,8 @@ ExportFilename::get_path (ExportFormatSpecPtr format) const
        path += ".";
        path += format->extension ();
 
+       path = legalize_for_universal_path (path);
+
        return Glib::build_filename (folder, path);
 }
 
index d9310c958a97f0cd8fbd61ad86f89294771454ed..d034eea6ee91df5f72694a9b8c8360d265724c3d 100644 (file)
@@ -60,18 +60,10 @@ using namespace ARDOUR;
 using namespace std;
 using namespace PBD;
 
-/** take an arbitrary string as an argument, and return a version of it
- * suitable for use as a path (directory/folder name). This is the Ardour 3.X
- * and later version of this code. It defines a very small number
- * of characters that are not allowed in a path on any of our target
- * filesystems, and replaces any instances of them with an underscore.
- */
-
-string
-legalize_for_path (const string& str)
+static string
+replace_chars (const string& str, const string& illegal_chars)
 {
        string::size_type pos;
-       string illegal_chars = "/\\"; /* DOS, POSIX. Yes, we're going to ignore HFS */
        Glib::ustring legal;
 
        /* this is the one place in Ardour where we need to iterate across
@@ -88,6 +80,36 @@ legalize_for_path (const string& str)
 
        return string (legal);
 }
+/** take an arbitrary string as an argument, and return a version of it
+ * suitable for use as a path (directory/folder name). This is the Ardour 3.X
+ * and later version of this code. It defines a very small number of characters
+ * that are not allowed in a path on the build target filesystem (basically,
+ * POSIX or Windows) and replaces any instances of them with an underscore.
+ *
+ * NOTE: this is intended only to legalize for the filesystem that Ardour
+ * is running on. Export should use legalize_for_universal_path() since
+ * the goal there is to be legal across filesystems.
+ */
+string
+legalize_for_path (const string& str)
+{
+       return replace_chars (str, "/\\");
+}
+
+/** take an arbitrary string as an argument, and return a version of it
+ * suitable for use as a path (directory/folder name). This is the Ardour 3.X
+ * and later version of this code. It defines a small number
+ * of characters that are not allowed in a path on any of our target
+ * filesystems, and replaces any instances of them with an underscore.
+ *
+ * NOTE: this is intended to create paths that should be legal on
+ * ANY filesystem.
+ */
+string
+legalize_for_universal_path (const string& str)
+{
+       return replace_chars (str, "<>:\"/\\|?*");
+}
 
 /** take an arbitrary string as an argument, and return a version of it
  * suitable for use as a path (directory/folder name). This is the Ardour 2.X