Replace use of PBD::sys::path in ardour/session_state_utils.h
authorTim Mayberry <mojofunk@gmail.com>
Sat, 23 Jun 2012 05:07:02 +0000 (05:07 +0000)
committerTim Mayberry <mojofunk@gmail.com>
Sat, 23 Jun 2012 05:07:02 +0000 (05:07 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@12832 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/session_state_utils.h
libs/ardour/session_state.cc
libs/ardour/session_state_utils.cc

index 57fcf54ac4957e97779c72f7cd388bbae00e17ef..166b738d05299b67e0006504c3cb2757ff806b6a 100644 (file)
@@ -22,8 +22,6 @@
 #include <vector>
 #include <string>
 
-#include "pbd/filesystem.h"
-
 namespace ARDOUR {
 
 /**
@@ -34,7 +32,7 @@ namespace ARDOUR {
  *
  * @return true if successful, false otherwise.
  */
-bool create_backup_file (const PBD::sys::path & file_path);
+bool create_backup_file (const std::string & file_path);
 
 /**
  * Get the absolute paths to all state files in the directory
index 2abdc6f16b2a526095b62ae703c712d4a9cb0766..3656e0f07eac41370c5789b407f4267f916c29cc 100644 (file)
@@ -681,9 +681,9 @@ Session::remove_state (string snapshot_name)
                return;
        }
 
-       sys::path xml_path(_session_dir->root_path());
+       std::string xml_path(_session_dir->root_path());
 
-       xml_path /= legalize_for_path (snapshot_name) + statefile_suffix;
+       xml_path = Glib::build_filename (xml_path, legalize_for_path (snapshot_name) + statefile_suffix);
 
        if (!create_backup_file (xml_path)) {
                // don't remove it if a backup can't be made
@@ -753,7 +753,7 @@ int
 Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot)
 {
        XMLTree tree;
-       sys::path xml_path(_session_dir->root_path());
+       std::string xml_path(_session_dir->root_path());
 
        if (!_writable || (_state_of_the_state & CannotSave)) {
                return 1;
@@ -788,7 +788,7 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot
 
                /* proper save: use statefile_suffix (.ardour in English) */
 
-               xml_path /= legalize_for_path (snapshot_name) + statefile_suffix;
+               xml_path = Glib::build_filename (xml_path, legalize_for_path (snapshot_name) + statefile_suffix);
 
                /* make a backup copy of the old file */
 
@@ -800,7 +800,7 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot
        } else {
 
                /* pending save: use pending_suffix (.pending in English) */
-               xml_path /= legalize_for_path (snapshot_name) + pending_suffix;
+               xml_path = Glib::build_filename (xml_path, legalize_for_path (snapshot_name) + pending_suffix);
        }
 
        sys::path tmp_path(_session_dir->root_path());
@@ -816,9 +816,9 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot
 
        } else {
 
-               if (::rename (tmp_path.to_string().c_str(), xml_path.to_string().c_str()) != 0) {
+               if (::rename (tmp_path.to_string().c_str(), xml_path.c_str()) != 0) {
                        error << string_compose (_("could not rename temporary session file %1 to %2"),
-                                       tmp_path.to_string(), xml_path.to_string()) << endmsg;
+                                       tmp_path.to_string(), xml_path) << endmsg;
                        sys::remove (tmp_path);
                        return -1;
                }
index 8cfda28780eb3ee5fd4f69f81d4ea2d024b1ef70..be71289a179086d1b67b7c5205221f508164f42f 100644 (file)
 
 #include <algorithm>
 
+#include <glibmm/fileutils.h>
+
 #include "pbd/compose.h"
 #include "pbd/error.h"
 #include "pbd/file_utils.h"
+#include "pbd/filesystem.h"
 
 #include "ardour/session_state_utils.h"
 #include "ardour/filename_extensions.h"
@@ -33,11 +36,11 @@ using namespace PBD;
 namespace ARDOUR {
 
 bool
-create_backup_file (const sys::path & file_path)
+create_backup_file (const std::string & file_path)
 {
-       if (!sys::exists (file_path)) return false;
+       if (!Glib::file_test (file_path, Glib::FILE_TEST_EXISTS)) return false;
 
-       sys::path backup_path(file_path.to_string() + backup_suffix);
+       std::string backup_path(file_path + backup_suffix);
 
        try
        {
@@ -46,7 +49,7 @@ create_backup_file (const sys::path & file_path)
        catch(sys::filesystem_error& ex)
        {
                error << string_compose (_("Unable to create a backup copy of file %1 (%2)"),
-                               file_path.to_string(), ex.what())
+                               file_path, ex.what())
                        << endmsg;
                return false;
        }