remove all use of access(2) (this was done a bit stupidly, we could have used g_access)
authorPaul Davis <paul@linuxaudiosystems.com>
Sat, 9 Apr 2011 15:38:42 +0000 (15:38 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Sat, 9 Apr 2011 15:38:42 +0000 (15:38 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@9340 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor_export_audio.cc
gtk2_ardour/export_range_markers_dialog.cc
libs/ardour/audiosource.cc
libs/ardour/file_source.cc
libs/ardour/session_state.cc

index 7b77f190990963c393730d6644b128e3aa93f1b0..2eff80614ebdeafd365b191cf1e7d8452cda602b 100644 (file)
@@ -221,7 +221,7 @@ Editor::write_region (string path, boost::shared_ptr<AudioRegion> region)
 
                                path = s;
 
-                               if (::access (path.c_str(), F_OK) != 0) {
+                               if (!Glib::file_test (path, Glib::FILE_TEST_EXISTS)) {
                                        break;
                                }
                        }
@@ -360,7 +360,7 @@ Editor::write_audio_range (AudioPlaylist& playlist, const ChanCount& count, list
                                          legalize_for_path(playlist.name()).c_str(), cnt, n);
                        }
 
-                       if (::access (s, F_OK) != 0) {
+                       if (!Glib::file_test (s, Glib::FILE_TEST_EXISTS)) {
                                break;
                        }
                }
index 774a956d9ecb3b1b8fb59da79bf26c1446be259b..06f590758c7d7602f27723e70fd960697e6d4d97 100644 (file)
@@ -22,6 +22,8 @@
 
 #include <sstream>
 
+#include "pbd/filesystem.h"
+
 #include "ardour/audioengine.h"
 #include "ardour/sndfile_helpers.h"
 
@@ -155,7 +157,7 @@ ExportRangeMarkersDialog::is_filepath_valid(string &filepath)
 
        // directory needs to exist and be writable
        string dirpath = Glib::path_get_dirname (filepath);
-       if (::access (dirpath.c_str(), W_OK) != 0) {
+       if (!exists_and_writable (sys::path (dirpath))) {
                string txt = _("Cannot write file in: ") + dirpath;
                MessageDialog msg (*this, txt, false, MESSAGE_ERROR, BUTTONS_OK, true);
                msg.run();
index b993a093b50b0eda3087bee4ac25154c4e08c9f9..ac98837183ce7ddef4e8917fa3b1172cd91b306b 100644 (file)
@@ -197,7 +197,7 @@ AudioSource::rename_peakfile (string newpath)
 
        string oldpath = peakpath;
 
-       if (access (oldpath.c_str(), F_OK) == 0) {
+       if (Glib::file_test (oldpath, Glib::FILE_TEST_EXISTS)) {
                if (rename (oldpath.c_str(), newpath.c_str()) != 0) {
                        error << string_compose (_("cannot rename peakfile for %1 from %2 to %3 (%4)"), _name, oldpath, newpath, strerror (errno)) << endmsg;
                        return -1;
index 5522031d691d6438db88fc9f513adc311bca9635..e6990aa487bfa09f2f1e896bde3add2632f6ee57 100644 (file)
@@ -191,7 +191,7 @@ FileSource::move_to_trash (const string& trash_dir_name)
                snprintf (buf, sizeof (buf), "%s.%d", newpath.c_str(), version);
                newpath_v = buf;
 
-               while (access (newpath_v.c_str(), F_OK) == 0 && version < 999) {
+               while (Glib::file_test (newpath_v, Glib::FILE_TEST_EXISTS) && version < 999) {
                        snprintf (buf, sizeof (buf), "%s.%d", newpath.c_str(), ++version);
                        newpath_v = buf;
                }
index b5b713cbd4af8b69894cb5224d9387ed0e7c7fb6..616f19c50a70efd91eb028616b20f295ab5e722b 100644 (file)
@@ -130,6 +130,7 @@ using namespace std;
 using namespace ARDOUR;
 using namespace PBD;
 
+
 void
 Session::first_stage_init (string fullpath, string snapshot_name)
 {
@@ -151,11 +152,7 @@ Session::first_stage_init (string fullpath, string snapshot_name)
                _path += G_DIR_SEPARATOR;
        }
 
-       if (Glib::file_test (_path, Glib::FILE_TEST_EXISTS) && ::access (_path.c_str(), W_OK)) {
-               _writable = false;
-       } else {
-               _writable = true;
-       }
+       _writable = exists_and_writable (sys::path (_path));
 
        /* these two are just provisional settings. set_state()
           will likely override them.
@@ -898,14 +895,7 @@ Session::load_state (string snapshot_name)
 
        set_dirty();
 
-       /* writable() really reflects the whole folder, but if for any
-          reason the session state file can't be written to, still
-          make us unwritable.
-       */
-
-       if (::access (xmlpath.to_string().c_str(), W_OK) != 0) {
-               _writable = false;
-       }
+       _writable = exists_and_writable (xmlpath);
 
        if (!state_tree->read (xmlpath.to_string())) {
                error << string_compose(_("Could not understand ardour file %1"), xmlpath.to_string()) << endmsg;