13
0

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
This commit is contained in:
Paul Davis 2012-12-20 13:08:50 +00:00
parent e9f1b1287b
commit 57bcb2182f
3 changed files with 36 additions and 10 deletions

View 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);

View 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);
}

View 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