centralize legal-session-name-checkng and include : and ; in characters that we disallow, because they conflict with search path conventions on *nix and windows
git-svn-id: svn://localhost/ardour2/branches/3.0@10943 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
26366a4062
commit
86ac8536d2
@ -2280,15 +2280,11 @@ ARDOUR_UI::rename_session ()
|
||||
bool do_rename = (name.length() != 0);
|
||||
|
||||
if (do_rename) {
|
||||
if (name.find ('/') != string::npos) {
|
||||
MessageDialog msg (_("To ensure compatibility with various systems\n"
|
||||
"session names may not contain a '/' character"));
|
||||
msg.run ();
|
||||
goto again;
|
||||
}
|
||||
if (name.find ('\\') != string::npos) {
|
||||
MessageDialog msg (_("To ensure compatibility with various systems\n"
|
||||
"session names may not contain a '\\' character"));
|
||||
char illegal = Session::session_name_is_legal (name);
|
||||
|
||||
if (illegal) {
|
||||
MessageDialog msg (string_compose (_("To ensure compatibility with various systems\n"
|
||||
"session names may not contain a '%1' character"), illegal));
|
||||
msg.run ();
|
||||
goto again;
|
||||
}
|
||||
@ -2666,19 +2662,13 @@ ARDOUR_UI::get_session_parameters (bool quit_on_cancel, bool should_be_new, stri
|
||||
|
||||
session_path = _startup->session_folder();
|
||||
|
||||
if (session_name.find ('/') != string::npos) {
|
||||
MessageDialog msg (*_startup,
|
||||
_("To ensure compatibility with various systems\n"
|
||||
"session names may not contain a '/' character"));
|
||||
msg.run ();
|
||||
ARDOUR_COMMAND_LINE::session_name = ""; // cancel that
|
||||
continue;
|
||||
}
|
||||
char illegal = Session::session_name_is_legal (session_name);
|
||||
|
||||
if (session_name.find ('\\') != string::npos) {
|
||||
if (illegal) {
|
||||
MessageDialog msg (*_startup,
|
||||
_("To ensure compatibility with various systems\n"
|
||||
"session names may not contain a '\\' character"));
|
||||
string_compose (_("To ensure compatibility with various systems\n"
|
||||
"session names may not contain a '%1' character"),
|
||||
illegal));
|
||||
msg.run ();
|
||||
ARDOUR_COMMAND_LINE::session_name = ""; // cancel that
|
||||
continue;
|
||||
|
@ -238,6 +238,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
|
||||
template<class T> void foreach_route (T *obj, void (T::*func)(boost::shared_ptr<Route>));
|
||||
template<class T, class A> void foreach_route (T *obj, void (T::*func)(Route&, A), A arg);
|
||||
|
||||
static char session_name_is_legal (const std::string&);
|
||||
bool io_name_is_legal (const std::string&);
|
||||
boost::shared_ptr<Route> route_by_name (std::string);
|
||||
boost::shared_ptr<Route> route_by_id (PBD::ID);
|
||||
|
@ -4543,3 +4543,16 @@ Session::update_latency_compensation (bool force_whole_graph)
|
||||
}
|
||||
}
|
||||
|
||||
char
|
||||
Session::session_name_is_legal (const string& path)
|
||||
{
|
||||
char illegal_chars[] = { '/', '\\', ':', ';', '\0' };
|
||||
|
||||
for (int i = 0; illegal_chars[i]; ++i) {
|
||||
if (path.find (illegal_chars[i]) != string::npos) {
|
||||
return illegal_chars[i];
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user