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