remove extra use of legalize_for_path() and just make sure that session and snapshot...
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 6 Jul 2009 15:36:06 +0000 (15:36 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 6 Jul 2009 15:36:06 +0000 (15:36 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@5332 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/ardour_ui.cc
libs/ardour/ardour/utils.h
libs/ardour/session_state.cc
libs/ardour/utils.cc

index f99f5483985d339886683d93d63bcdf55feda17e..be60ac728e68b6c0fbd5dfc0fa7ccd94dbed9f6a 100644 (file)
@@ -1850,11 +1850,24 @@ ARDOUR_UI::snapshot_session ()
        prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
        prompter.set_prompt (_("Name of New Snapshot"));
        prompter.set_initial_text (timebuf);
-       
+
+  again:
        switch (prompter.run()) {
        case RESPONSE_ACCEPT:
                prompter.get_result (snapname);
                if (snapname.length()){
+                       if (snapname.find ('/')) {
+                               MessageDialog msg (_("To ensure compatibility with various systems\n"
+                                                    "snapshot names may not contain a '/' character"));
+                               msg.run ();
+                               goto again;
+                       }
+                       if (snapname.find ('\\')) {
+                               MessageDialog msg (_("To ensure compatibility with various systems\n"
+                                                    "snapshot names may not contain a '\\' character"));
+                               msg.run ();
+                               goto again;
+                       }
                        save_state (snapname);
                }
                break;
@@ -2209,7 +2222,6 @@ ARDOUR_UI::get_session_parameters (bool backend_audio_is_running, bool should_be
        Glib::ustring session_name;
        Glib::ustring session_path;
        Glib::ustring template_name;
-       Glib::ustring legal_session_folder_name;
        int response;
        
   begin:
@@ -2342,12 +2354,26 @@ ARDOUR_UI::get_session_parameters (bool backend_audio_is_running, bool should_be
                                
                                should_be_new = true;
 
-                               legal_session_folder_name = legalize_for_path (session_name);
+                               if (session_name.find ('/')) {
+                                       MessageDialog msg (*new_session_dialog, _("To ensure compatibility with various systems\n"
+                                                        "session names may not contain a '/' character"));
+                                       msg.run ();
+                                       response = RESPONSE_NONE;
+                                       goto try_again;
+                               }
+
+                               if (session_name.find ('\\')) {
+                                       MessageDialog msg (*new_session_dialog, _("To ensure compatibility with various systems\n"
+                                                        "session names may not contain a '\\' character"));
+                                       msg.run ();
+                                       response = RESPONSE_NONE;
+                                       goto try_again;
+                               }
 
                                //XXX This is needed because session constructor wants a 
                                //non-existant path. hopefully this will be fixed at some point.
 
-                               session_path = Glib::build_filename (session_path, legal_session_folder_name);
+                               session_path = Glib::build_filename (session_path, session_name);
 
                                if (Glib::file_test (session_path, Glib::FileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
 
index 5f392ca5b4abad5898df915a9dfaee58138dc943..9e0067c65243619a283814e5a10d1bcc8e320fd3 100644 (file)
@@ -32,8 +32,9 @@
 
 class XMLNode;
 
+Glib::ustring legalize_for_path (Glib::ustring);
+
 void elapsed_time_to_str (char *buf, uint32_t seconds);
-Glib::ustring legalize_for_path (Glib::ustring str);
 std::ostream& operator<< (std::ostream& o, const ARDOUR::BBT_Time& bbt);
 XMLNode* find_named_node (const XMLNode& node, std::string name);
 
index 9b696a6254b70d4ce15d1267f6222f363db7529a..6e13e3977f80b19c67443ae44cf2df56b48ef5d9 100644 (file)
@@ -601,7 +601,7 @@ Session::remove_pending_capture_state ()
        string xml_path;
 
        xml_path = _path;
-       xml_path += legalize_for_path (_current_snapshot_name);
+       xml_path += _current_snapshot_name;
        xml_path += _pending_suffix;
 
        unlink (xml_path.c_str());
@@ -618,8 +618,8 @@ Session::rename_state (string old_name, string new_name)
                return;
        }
        
-       const string old_xml_path = _path + legalize_for_path (old_name) + _statefile_suffix;
-       const string new_xml_path = _path + legalize_for_path (new_name) + _statefile_suffix;
+       const string old_xml_path = _path + old_name + _statefile_suffix;
+       const string new_xml_path = _path + new_name + _statefile_suffix;
 
        if (rename (old_xml_path.c_str(), new_xml_path.c_str()) != 0) {
                error << string_compose(_("could not rename snapshot %1 to %2"), old_name, new_name) << endmsg;
@@ -637,7 +637,7 @@ Session::remove_state (string snapshot_name)
                return;
        }
        
-       const string xml_path = _path + legalize_for_path (snapshot_name) + _statefile_suffix;
+       const string xml_path = _path + snapshot_name + _statefile_suffix;
 
        /* make a backup copy of the state file */
        const string bak_path = xml_path + ".bak";
@@ -676,7 +676,7 @@ Session::save_state (string snapshot_name, bool pending)
 
                /* proper save: use _statefile_suffix (.ardour in English) */
                xml_path = _path;
-               xml_path += legalize_for_path (snapshot_name);
+               xml_path += snapshot_name;
                xml_path += _statefile_suffix;
 
                /* make a backup copy of the old file */
@@ -691,7 +691,7 @@ Session::save_state (string snapshot_name, bool pending)
 
                /* pending save: use _pending_suffix (.pending in English) */
                xml_path = _path;
-               xml_path += legalize_for_path (snapshot_name);
+               xml_path += snapshot_name;
                xml_path += _pending_suffix;
 
        }
@@ -699,7 +699,7 @@ Session::save_state (string snapshot_name, bool pending)
        string tmp_path;
 
        tmp_path = _path;
-       tmp_path += legalize_for_path (snapshot_name);
+       tmp_path += snapshot_name;
        tmp_path += ".tmp";
 
        // cerr << "actually writing state to " << xml_path << endl;
@@ -762,7 +762,7 @@ Session::load_state (string snapshot_name)
        /* check for leftover pending state from a crashed capture attempt */
 
        xmlpath = _path;
-       xmlpath += legalize_for_path (snapshot_name);
+       xmlpath += snapshot_name;
        xmlpath += _pending_suffix;
 
        if (Glib::file_test (xmlpath, Glib::FILE_TEST_EXISTS)) {
@@ -777,7 +777,7 @@ Session::load_state (string snapshot_name)
        if (!state_was_pending) {
 
                xmlpath = _path;
-               xmlpath += legalize_for_path (snapshot_name);
+               xmlpath += snapshot_name;
                xmlpath += _statefile_suffix;
        }
        
@@ -824,7 +824,7 @@ Session::load_state (string snapshot_name)
                string backup_path;
 
                backup_path = _path;
-               backup_path += legalize_for_path (snapshot_name);
+               backup_path += snapshot_name;
                backup_path += "-1";
                backup_path += _statefile_suffix;
 
@@ -2666,7 +2666,7 @@ Session::find_all_sources_across_snapshots (set<string>& result, bool exclude_th
        }
 
        this_snapshot_path = _path;
-       this_snapshot_path += legalize_for_path (_current_snapshot_name);
+       this_snapshot_path += _current_snapshot_name;
        this_snapshot_path += _statefile_suffix;
 
        for (vector<string*>::iterator i = state_files->begin(); i != state_files->end(); ++i) {
@@ -3111,7 +3111,7 @@ Session::save_history (string snapshot_name)
        snapshot_name = _current_snapshot_name;
     }
 
-    xml_path = _path + legalize_for_path (snapshot_name) + ".history"; 
+    xml_path = _path + snapshot_name + ".history"; 
 
     bak_path = xml_path + ".bak";
 
@@ -3160,7 +3160,7 @@ Session::restore_history (string snapshot_name)
     }
 
     /* read xml */
-    xmlpath = _path + legalize_for_path (snapshot_name) + ".history";
+    xmlpath = _path + snapshot_name + ".history";
     cerr << string_compose(_("Loading history from '%1'."), xmlpath) << endmsg;
 
     if (!Glib::file_test (xmlpath, Glib::FILE_TEST_EXISTS)) {
index 8927e2a9c66cc6dad9cb1e5ca9d8ce9fbba4c840..684c4b49f6956a688b2658c189ec571d776a0fc6 100644 (file)
@@ -94,7 +94,7 @@ legalize_for_path (ustring str)
        ustring::size_type pos;
        ustring legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_+=: ";
        ustring legal;
-
+       
        legal = str;
        pos = 0;