diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2012-12-20 13:08:50 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2012-12-20 13:08:50 +0000 |
commit | 57bcb2182fa44ffb04f7b255a5676ef4af879b42 (patch) | |
tree | 42c32073d404918ef199a2d257024a5a2a131d88 | |
parent | e9f1b1287b62bfa4b1c2dc1113e37be125c60eed (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
-rw-r--r-- | libs/ardour/ardour/utils.h | 1 | ||||
-rw-r--r-- | libs/ardour/export_filename.cc | 3 | ||||
-rw-r--r-- | libs/ardour/utils.cc | 42 |
3 files changed, 36 insertions, 10 deletions
diff --git a/libs/ardour/ardour/utils.h b/libs/ardour/ardour/utils.h index 7a09f5e209..5e4cc3bdc4 100644 --- a/libs/ardour/ardour/utils.h +++ b/libs/ardour/ardour/utils.h @@ -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); diff --git a/libs/ardour/export_filename.cc b/libs/ardour/export_filename.cc index d00b0147a7..a5b0a07a60 100644 --- a/libs/ardour/export_filename.cc +++ b/libs/ardour/export_filename.cc @@ -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); } 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 |