summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2012-05-28 16:32:41 +0000
committerCarl Hetherington <carl@carlh.net>2012-05-28 16:32:41 +0000
commit7eb8a33910bfdab21b98d794dc731bc8e8557cb9 (patch)
tree8a22b28badb6f4bdfd9c9660c50f6e5c1605e8c9 /libs/ardour
parentd825f20a324dc05fae612b748c579c22df88a471 (diff)
Add path_is_within to decide if a path is within a given
directory, taking symlinks into account, and use it to decide whether a file is within the session folder. Should fix #4552. git-svn-id: svn://localhost/ardour2/branches/3.0@12468 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/ardour/utils.h1
-rw-r--r--libs/ardour/file_source.cc3
-rw-r--r--libs/ardour/session.cc4
-rw-r--r--libs/ardour/session_state.cc2
-rw-r--r--libs/ardour/utils.cc12
5 files changed, 5 insertions, 17 deletions
diff --git a/libs/ardour/ardour/utils.h b/libs/ardour/ardour/utils.h
index 7eba3fa18c..5052f03bab 100644
--- a/libs/ardour/ardour/utils.h
+++ b/libs/ardour/ardour/utils.h
@@ -61,7 +61,6 @@ std::string path_expand (std::string); /* single file path */
std::string search_path_expand (std::string); /* colon-separated search path */
std::string region_name_from_path (std::string path, bool strip_channels, bool add_channel_suffix = false, uint32_t total = 0, uint32_t this_one = 0);
bool path_is_paired (std::string path, std::string& pair_base);
-bool inodes_same (const std::string &, const std::string &);
void compute_equal_power_fades (ARDOUR::framecnt_t nframes, float* in, float* out);
diff --git a/libs/ardour/file_source.cc b/libs/ardour/file_source.cc
index fd3e9ef142..f4f3c40d9d 100644
--- a/libs/ardour/file_source.cc
+++ b/libs/ardour/file_source.cc
@@ -33,6 +33,7 @@
#include "pbd/strsplit.h"
#include "pbd/shortpath.h"
#include "pbd/enumwriter.h"
+#include "pbd/filesystem.h"
#include <glibmm/miscutils.h>
#include <glibmm/fileutils.h>
@@ -277,7 +278,7 @@ FileSource::find (Session& s, DataType type, const string& path, bool must_exist
++j;
while (j != hits.end()) {
- if (inodes_same (*i, *j)) {
+ if (PBD::sys::inodes_same (*i, *j)) {
/* *i and *j are the same file; break out of the loop early */
break;
}
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 37d4d2908f..fdddb3b2c2 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -4478,7 +4478,7 @@ Session::ensure_search_path_includes (const string& path, DataType type)
search_path = config.get_midi_search_path ();
break;
}
-
+
split (search_path, dirs, ':');
for (vector<string>::iterator i = dirs.begin(); i != dirs.end(); ++i) {
@@ -4488,7 +4488,7 @@ Session::ensure_search_path_includes (const string& path, DataType type)
On Windows, I think we could just do if (*i == path) here.
*/
- if (inodes_same (*i, path)) {
+ if (PBD::sys::inodes_same (*i, path)) {
return;
}
}
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index 4b40a80d80..e729a7b00d 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -428,7 +428,7 @@ bool
Session::path_is_within_session (const std::string& path)
{
for (vector<space_and_path>::const_iterator i = session_dirs.begin(); i != session_dirs.end(); ++i) {
- if (path.find ((*i).path) == 0) {
+ if (PBD::sys::path_is_within (i->path, path)) {
return true;
}
}
diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc
index beb003e713..8ab20ecc62 100644
--- a/libs/ardour/utils.cc
+++ b/libs/ardour/utils.cc
@@ -745,18 +745,6 @@ double slider_position_to_gain_with_max (double g, double max_gain)
return slider_position_to_gain (g * max_gain/2.0);
}
-/** @return true if files a and b have the same inode */
-bool
-inodes_same (const string& a, const string& b)
-{
- struct stat bA;
- int const rA = stat (a.c_str(), &bA);
- struct stat bB;
- int const rB = stat (b.c_str(), &bB);
-
- return (rA == 0 && rB == 0 && bA.st_ino == bB.st_ino);
-}
-
extern "C" {
void c_stacktrace() { stacktrace (cerr); }
}