diff options
Diffstat (limited to 'libs/ardour/utils.cc')
-rw-r--r-- | libs/ardour/utils.cc | 42 |
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 |