summaryrefslogtreecommitdiff
path: root/libs/ardour/utils.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-12-20 13:08:50 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-12-20 13:08:50 +0000
commit57bcb2182fa44ffb04f7b255a5676ef4af879b42 (patch)
tree42c32073d404918ef199a2d257024a5a2a131d88 /libs/ardour/utils.cc
parente9f1b1287b62bfa4b1c2dc1113e37be125c60eed (diff)
replace characters that would make an export filename illegal on any/all filesystems with "_"
git-svn-id: svn://localhost/ardour2/branches/3.0@13689 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/utils.cc')
-rw-r--r--libs/ardour/utils.cc42
1 files changed, 32 insertions, 10 deletions
diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc
index d9310c958a..d034eea6ee 100644
--- a/libs/ardour/utils.cc
+++ b/libs/ardour/utils.cc
@@ -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