Use std::string and Glib::build_filename in Session::save_template
authorTim Mayberry <mojofunk@gmail.com>
Sat, 23 Jun 2012 05:09:37 +0000 (05:09 +0000)
committerTim Mayberry <mojofunk@gmail.com>
Sat, 23 Jun 2012 05:09:37 +0000 (05:09 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@12899 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/session_state.cc

index 42040d29a14017f4b320d0650754deb5292deb2c..81c399d2a2f4af63029893cc921727fad47497eb 100644 (file)
@@ -2028,53 +2028,54 @@ Session::save_template (string template_name)
                return -1;
        }
 
-       sys::path user_template_dir(user_template_directory());
+       std::string user_template_dir(user_template_directory());
 
-       if (g_mkdir_with_parents (user_template_dir.to_string().c_str(), 0755) != 0) {
+       if (g_mkdir_with_parents (user_template_dir.c_str(), 0755) != 0) {
                error << string_compose(_("Could not create templates directory \"%1\" (%2)"),
-                               user_template_dir.to_string(), g_strerror (errno)) << endmsg;
+                               user_template_dir, g_strerror (errno)) << endmsg;
                return -1;
        }
 
        tree.set_root (&get_template());
 
-       sys::path template_dir_path(user_template_dir);
+       std::string template_dir_path(user_template_dir);
        
        /* directory to put the template in */
-       template_dir_path /= template_name;
-       if (Glib::file_test (template_dir_path.to_string(), Glib::FILE_TEST_EXISTS)) {
+       template_dir_path = Glib::build_filename (template_dir_path, template_name);
+
+       if (Glib::file_test (template_dir_path, Glib::FILE_TEST_EXISTS)) {
                warning << string_compose(_("Template \"%1\" already exists - new version not created"),
-                               template_dir_path.to_string()) << endmsg;
+                               template_dir_path) << endmsg;
                return -1;
        }
        
-       if (g_mkdir_with_parents (template_dir_path.to_string().c_str(), 0755) != 0) {
+       if (g_mkdir_with_parents (template_dir_path.c_str(), 0755) != 0) {
                error << string_compose(_("Could not create directory for Session template\"%1\" (%2)"),
-                               template_dir_path.to_string(), g_strerror (errno)) << endmsg;
+                               template_dir_path, g_strerror (errno)) << endmsg;
                return -1;
        }
 
        /* file to write */
-       sys::path template_file_path = template_dir_path;
-       template_file_path /= template_name + template_suffix;
+       std::string template_file_path(template_dir_path);
+       template_file_path = Glib::build_filename (template_file_path, template_name + template_suffix);
 
-       if (!tree.write (template_file_path.to_string())) {
+       if (!tree.write (template_file_path)) {
                error << _("template not saved") << endmsg;
                return -1;
        }
 
        /* copy plugin state directory */
 
-       sys::path template_plugin_state_path = template_dir_path;
-       template_plugin_state_path /= X_("plugins");
+       std::string template_plugin_state_path(template_dir_path);
+       template_plugin_state_path = Glib::build_filename (template_plugin_state_path, X_("plugins"));
 
-       if (g_mkdir_with_parents (template_plugin_state_path.to_string().c_str(), 0755) != 0) {
+       if (g_mkdir_with_parents (template_plugin_state_path.c_str(), 0755) != 0) {
                error << string_compose(_("Could not create directory for Session template plugin state\"%1\" (%2)"),
-                               template_plugin_state_path.to_string(), g_strerror (errno)) << endmsg;
+                               template_plugin_state_path, g_strerror (errno)) << endmsg;
                return -1;
        }
 
-       copy_files (plugins_dir(), template_plugin_state_path.to_string());
+       copy_files (plugins_dir(), template_plugin_state_path);
 
        return 0;
 }