summaryrefslogtreecommitdiff
path: root/libs/ardour/utils.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-10-23 14:52:26 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-10-23 14:52:26 +0000
commit35c6b52c36ca047ada5b1b127128c03049ebfc89 (patch)
tree0ae4967ae71420d94bf1053dbb44d725689d8734 /libs/ardour/utils.cc
parent506adcb7a2cd237cecdac151fd2682506a55ac89 (diff)
probable fix for not being able to find audio files in a 2.X session that had "illegal" characters in the session name - adds the 2.X version of the search path to the audio file search path, if it exists
git-svn-id: svn://localhost/ardour2/branches/3.0@13321 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/utils.cc')
-rw-r--r--libs/ardour/utils.cc43
1 files changed, 42 insertions, 1 deletions
diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc
index 8c990a5e88..d9310c958a 100644
--- a/libs/ardour/utils.cc
+++ b/libs/ardour/utils.cc
@@ -60,12 +60,23 @@ 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)
{
string::size_type pos;
string illegal_chars = "/\\"; /* DOS, POSIX. Yes, we're going to ignore HFS */
- string legal;
+ Glib::ustring legal;
+
+ /* this is the one place in Ardour where we need to iterate across
+ * potential multibyte characters, and thus we need Glib::ustring
+ */
legal = str;
pos = 0;
@@ -78,6 +89,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 2.X
+ * version of this code, which used an approach that came to be seen as
+ * problematic: defining the characters that were allowed and replacing all
+ * others with underscores. See legalize_for_path() for the 3.X and later
+ * version.
+ */
+
+string
+legalize_for_path_2X (const string& str)
+{
+ string::size_type pos;
+ string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_+=: ";
+ Glib::ustring legal;
+
+ /* this is the one place in Ardour where we need to iterate across
+ * potential multibyte characters, and thus we need Glib::ustring
+ */
+
+ legal = str;
+ pos = 0;
+
+ while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
+ legal.replace (pos, 1, "_");
+ pos += 1;
+ }
+
+ return string (legal);
+}
+
string
bump_name_once (const std::string& name, char delimiter)
{