fix crash when copy'ing latent plugins
[ardour.git] / libs / ardour / session_state_utils.cc
index 136598efc4a8e78b5150cb43605f834c71c9af24..28cfbb2b756eb6019f4ca2bcb06f032a2cce46e2 100644 (file)
@@ -30,7 +30,7 @@
 #include "ardour/session_state_utils.h"
 #include "ardour/filename_extensions.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace PBD;
@@ -40,33 +40,15 @@ namespace ARDOUR {
 bool
 create_backup_file (const std::string & file_path)
 {
-       if (!Glib::file_test (file_path, Glib::FILE_TEST_EXISTS)) return false;
-
-       Glib::RefPtr<Gio::File> backup_path = Gio::File::create_for_path(file_path + backup_suffix);
-       Glib::RefPtr<Gio::File> path = Gio::File::create_for_path(file_path);
-
-       try
-       {
-               path->copy (backup_path);
-       }
-       catch(const Glib::Exception& ex)
-       {
-               error << string_compose (_("Unable to create a backup copy of file %1 (%2)"),
-                               file_path, ex.what())
-                       << endmsg;
-               return false;
-       }
-       return true;
+       return copy_file (file_path, file_path + backup_suffix);
 }
 
 void
 get_state_files_in_directory (const std::string & directory_path,
                              vector<std::string> & result)
 {
-       Glib::PatternSpec state_file_pattern('*' + string(statefile_suffix));
-
-       find_matching_files_in_directory (directory_path, state_file_pattern,
-                       result);
+       find_files_matching_pattern (result, directory_path,
+                                    '*' + string(statefile_suffix));
 }
 
 vector<string>